[英]Rails render partial in a modal
I'm really struggling to show a partial in a modal that will feature local variables. 我真的很努力地展示以局部变量为特征的模态的一部分。 I'm new at Javascript and can't seem to figure out how to render the partial in a new dialog-form.
我是Java语言的新手,似乎无法弄清楚如何以新的对话框形式呈现部分内容。 Currently, I render the partial with "display:none" and, upon clicking "Click me", the partial is revealed on the page and an empty dialog box opens.
当前,我使用“ display:none”渲染部分,然后单击“单击我”,部分将显示在页面上,并打开一个空对话框。 Unfortunately, my intent is to show the partial IN the dialog box, which just isn't working.
不幸的是,我的目的是在对话框中显示部分对话框,但该对话框无法正常工作。
The view: 风景:
<div id="groups_show" style="display:none">
<%= render partial: 'groups/group_full', :locals => {:group => group} %>
</div>
<%= link_to "Click me", root_url, class: "groups_showme" %>
Javascript: 使用Javascript:
$('.groups_showme').on('click', function(e) {
e.preventDefault();
$('#groups_show').show();
var htmlString = $(this).html();
var dialog_form = $('<div id="dialog-form">Loading</div>').dialog({
autoOpen: false,
width: 520,
modal: true,
open: function() {
return $(this).html( htmlString );
},
close: function() {
$('#dialog-form').remove();
}
});
Perhaps this will work for you 也许这对你有用
$('.groups_showme').on('click', function(e) {
e.preventDefault();
$('<div id="dialog-form">Loading</div>').dialog({
autoOpen: true,
width: 520,
modal: true,
open: function() {
$(this).append($('#groups_show').show());
},
close: function() {
}
});
});
See here http://fiddle.jshell.net/aeuzF/3/ 看到这里http://fiddle.jshell.net/aeuzF/3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.