gpt4 book ai didi

ruby-on-rails - Rails 远程与 Bootstrap 远程模式冲突

转载 作者:行者123 更新时间:2023-12-03 12:19:46 26 4
gpt4 key购买 nike

我在使用 Twitter Bootstrap 和 Rails 数据远程链接时遇到问题。

我用 data-remote="/path/to/data" 加载模态内容.一切都按我的意愿工作,但创建两个请求。

= link_to '#myModal', 'Click here', data: {toggle: 'modal', remote: '/path'}

第一个是 rails data-reomte,他向我所在的页面发出请求,然后 Bootstrap 发出他的请求并显示模式。

有什么办法可以在指定的链接上远程打开rails,还是实际上是另一个问题?

最佳答案

根据 Modal 上的 Bootstrap 文档:http://twitter.github.io/bootstrap/javascript.html#modals

if you're using the data api, you may alternatively use the href tag to specify the remote source. An example of this is shown below:


<a data-toggle="modal" href="remote.html" data-target="#modal">click me</a>

因此,您可以通过禁用 Rails UJS 数据 api 并使用 Bootstrap 来满足您的请求。像这样
<a data-toggle="modal" href="remote.html" data-target="#modal" 
data-remote="false">click me</a>

在你的情况下。服务器端代码
= link_to 'Click here', '/path_for_bootstrap',
data: {toggle: 'modal', remote: false, target: "#myModal"}

更新 或者更好,不需要定义 remote完全因为没有人需要它,无论是 Bootstrap 还是 UJS!
= link_to 'Click here', '/path_for_bootstrap',
data: {toggle: 'modal', target: "#myModal"}

关于ruby-on-rails - Rails 远程与 Bootstrap 远程模式冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16363293/

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