簡體   English   中英

在導軌模態中渲染部分

[英]Rendering partial in rails modal

我在模態窗口中渲染部分時遇到問題。 我已經嘗試過簡單模態和原型窗口。 我基本上試圖在模態彈出窗口中渲染部分內容。 這是現在的樣子:

<%=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位以及在簡單模態下嘗試這個。

任何幫助將非常感激。

我認為更容易渲染頁面上的部分(隱藏),然后在按下按鈕時使用setContent將其捕獲到窗口中。 這意味着你可以把更多的j放在頁面之外,這也會更好一些。

在視圖中:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM