Ruby on rails的弹出窗口

时间:2013-10-09 19:43:10

标签: javascript ruby-on-rails

我将Popup的javascript作为POPUP.JS

在我看来,我想使用弹出窗口

 <%= 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']%>

显示为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>

但我需要HTML作为

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

有人可以为this.hide()ans的语法提供帮助吗?开始考试

1 个答案:

答案 0 :(得分:3)

Rails 3已弃用:popup所以现在最好自己编写弹出式JS。对于您可以执行的链接:

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

然后在你的JS中你会得到这个:

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