javascript Ruby on rails 的弹出窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19281138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Popup window for Ruby on rails
提问by Raja Sekar
I have javascript for Popup as POPUP.JS
我有 Popup 的 javascript 作为 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
它显示为 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
但我需要那个 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>
Can anyone help for the syntax for this.hide() ans ? Start Exam
任何人都可以帮助 this.hide() ans 的语法吗?开始考试
回答by dgmdan
Rails 3 deprecated :popup
so it's best to write the popup JS yourself now. For the link you could do:
Rails 3 已弃用,:popup
因此最好现在自己编写弹出式 JS。对于链接,您可以执行以下操作:
<%= link_to "Start" , answer_exam_group_answers_path(@exam_group), :class => "submit_button", :onclick => 'return openPopup(this);' %>
<%= 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:
然后在您的 JS 中,您将拥有以下内容:
function openPopup(link)
{
link.hide();
window.open(link.href,'exam_dialog','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no');
return false;
}