Rajasekar Sankar
Rajasekar Sankar

Reputation: 101

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

Upvotes: 1

Views: 13795

Answers (1)

dgmdan
dgmdan

Reputation: 415

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;
}

Upvotes: 3

Related Questions