简体   繁体   中英

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.

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. This would mean you could put the more of the js outside the page, which would be a bit nicer too.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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