gpt4 book ai didi

javascript - 在 rails 模态中呈现部分

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:37:40 24 4
gpt4 key购买 nike

我在模态窗口中呈现局部时遇到问题。我已经尝试过简单模式和原型(prototype)窗口。我基本上是在尝试在模式弹出窗口中渲染一个部分。这是它现在的样子:

<%=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 将其捕获到窗口中会更容易。这意味着您可以将更多的 js 放在页面之外,这样也会更好一些。

在 View 中:

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

关于javascript - 在 rails 模态中呈现部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9402700/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com