javascript - Rendering partial in rails modal - Stack Overflow

I'm having an issue with rendering a partial in a modal window. I've tried it with both simpl

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 binations of how to put the escape_javascript bit as well as trying this in simple modal.

Any help would be really appreciated.

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 binations of how to put the escape_javascript bit as well as trying this in simple modal.

Any help would be really appreciated.

Share Improve this question asked Feb 22, 2012 at 20:48 pashpash 1071 silver badge8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745635547a4637370.html

相关推荐

  • javascript - Rendering partial in rails modal - Stack Overflow

    I'm having an issue with rendering a partial in a modal window. I've tried it with both simpl

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信