简体   繁体   中英

Popup window for Ruby on rails

I have javascript for Popup as POPUP.JS

In my view i want to use the popup

 <%= link_to "Start" , answer_exam_group_answers_path(@exam_group), :class => "submit_button", :popup => ['exam_dialog','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,fullscren=yes,resizable=no']%>

It displayed as HTML

<a href="/exam_groups/1/answers/answer" class="submit_button" onclick="window.open(this.href,'exam_dialog','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,fullscren=yes,resizable=no');return false;">Start</a>

But i need that HTML as

<a href="/online_student_exam/start_exam/1743" class="user_button" onclick="this.hide();window.open(this.href,'exam_dialog','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no');return false;" style="display: none;"> ? Start Exam</a>

Can anyone help for the syntax for this.hide() ans ? Start Exam

Rails 3 deprecated :popup so it's best to write the popup JS yourself now. For the link you could do:

<%= link_to "Start" , answer_exam_group_answers_path(@exam_group), :class => "submit_button", :onclick => 'return openPopup(this);' %>

Then in your JS you would have this:

function openPopup(link)
{
    link.hide();
    window.open(link.href,'exam_dialog','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no');
    return false;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM