简体   繁体   English

在导轨模态中渲染部分

[英]Rendering partial in rails modal

I'm having an issue with rendering a partial in a modal window. 我在模态窗口中渲染部分时遇到问题。 I've tried it with both simple modal as well as prototype-window. 我已经尝试过简单模态和原型窗口。 I'm basically trying to render a partial within the modal popup. 我基本上试图在模态弹出窗口中渲染部分内容。 Here is what it looks like now: 这是现在的样子:

<%=link_to_function("Share This!", "win = new Window({title: \"Share This\", width:200, height:150, destroyOnClose: true, recenterAuto:false});
win.getContent().update("+escape_javascript(render :partial => 'groups/show')+");
win.showCenter();
")%>

I've tried multiple combinations of how to put the escape_javascript bit as well as trying this in simple modal. 我已经尝试了多种组合,如何放置escape_javascript位以及在简单模态下尝试这个。

Any help would be really appreciated. 任何帮助将非常感激。

I'm thinking it would be easier render the partial on the page (hidden) and then capture it into the window using setContent when the button's pressed. 我认为更容易渲染页面上的部分(隐藏),然后在按下按钮时使用setContent将其捕获到窗口中。 This would mean you could put the more of the js outside the page, which would be a bit nicer too. 这意味着你可以把更多的j放在页面之外,这也会更好一些。

In the view: 在视图中:

<div id="groups_show" style="display:none">
  <%= render :partial => 'groups/show' %> 
</div>

<%= link_to_function("Share This!", "show_group_popup()") %>

In application.js (or other included js file): 在application.js(或其他包含的js文件)中:

function show_group_popup() {
  $('groups_show').show();
  win = new Window({title: "Share This", width:200, height:150, destroyOnClose: true, recenterAuto:false});
  win.setContent('groups_show',true,true);
  win.show();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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