(Rails) 使用“link_to_remote” 与弹出/弹出窗口结合使用...?

发布于 2024-07-26 22:39:49 字数 168 浏览 8 评论 0原文

“link_to_remote”并弹出包含数据的窗口的最直接的机制是什么? 我需要“link_to_remote”,因为我需要将某些数据与 url 一起传递,而不需要重做我的路线。 如果“link_to”可以更好地服务而不需要重做我的路线,我完全赞成。 我根本无法让它工作,atm。

想法?

What is the most straightforward mechanism by which to "link_to_remote" and popout a window with the data? I need "link_to_remote" because I need to pass certain data along with the url without redoing my routes. If this would be better served by a "link_to" without the need to redo my routes, I'm all for it. I simply can't get it to work, atm.

Thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

許願樹丅啲祈禱 2024-08-02 22:39:50

也许您正在寻找类似的东西:

<%= link_to_function "Show Article in Popout window",
      "window.open(#{article_path(article).to_json}, 'show_article')" %>

Perhaps you're looking for something like:

<%= link_to_function "Show Article in Popout window",
      "window.open(#{article_path(article).to_json}, 'show_article')" %>
脸赞 2024-08-02 22:39:50

link_to_remote 用于执行 XHR 请求,因此您不能使用它来打开包含响应的弹出窗口。

无论如何,您不需要重做您的路线,因为我假设如果您想使用 link_to* 来获取一些数据,那么您已经定义了控制器/操作对并可以访问。

此外,通常,Rails 应用程序会启用 catch all 路由来匹配 :controller/:action。 如果这是您的情况,那么您可以使用该控制器/操作的 link_to 来获取数据。

link_to_remote is used to do XHR requests, so you cannot use it to open a popup window with the response.

You don't need to redo your route anyway, because I assume that if you want to use link_to* to get some data, then you have your controller/action pair defined and accessible already.

Also, usually, Rails applications have the catch all route enabled to match :controller/:action. If that's your case, then you can use link_to that controller/action to get the data.

对岸观火 2024-08-02 22:39:50

你指的是什么窗口? 模态窗口 ? 如果你想通过模态窗口显示一些数据,那么我建议你使用 http://prototype -window.xilinus.com/index.html,使用起来更方便,只需编写一些js函数并在rails helper/view中创建link_to_function来调用js函数即可。

What window do u mean ? modal window ? if u want to show some data through modal window, then i suggest u to use http://prototype-window.xilinus.com/index.html, it easier to use, just write some js function and create link_to_function in rails helper/view to call the js function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文