2012-02-22 115 views
3

我在模态窗口中渲染部分时遇到问题。我已经用简单的模态以及原型窗口对它进行了尝试。我基本上是试图在模态弹出窗口中渲染一个部分。下面是它看起来像现在:渲染部分在轨道模式

<%=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(); 
")%> 

我已经试过了如何把escape_javascript位以及在简单模式尝试这种多重组合。

任何帮助将非常感激。

回答

5

我想这会更容易呈现页面上的部分(隐藏),然后使用setContent将其捕获到窗口中,当按钮被按下时。这意味着你可以把更多的js放在页面外面,这也会更好一些。

在视图:

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

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

在的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(); 
} 
+0

辉煌! (而且更干净)。谢谢! – pash 2012-02-23 15:33:12