gpt4 book ai didi

ruby-on-rails - 使用 Turbolinks 和 jQuery Turbolinks

转载 作者:太空宇宙 更新时间:2023-11-03 16:27:02 26 4
gpt4 key购买 nike

我看到在 Gemfile 中加载了两个 gem,那么加载这两个 gem 还是只使用一个是否有意义?

gem 'jquery-turbolinks'
gem 'turbolinks'

谁能告诉我为什么使用这两种 gem ?

最佳答案

如概述here jquery-turbolinks gem 修复了由于 turbolinks 触发 ajax 请求而不是通常的页面重新加载而不总是触发的绑定(bind)事件。

如果你的 javascript 很少,可以随意删除它,但如果你有一些停止工作的 .bind(...) 事件,请阅读 gem 的文档,你可能可以使用它来从文档中修复它:

But if you have a large codebase with lots of $(el).bind(...) Turbolinks will surprise you. Most part of your JavaScripts will stop working in usual way. It's because the nodes on which you bind events no longer exist.

I wrote jquery.turbolinks to solve this problem in my project. It's easy to use: just require it immediately after jquery.js. Your other scripts should be loaded after jquery.turbolinks.js, and turbolinks.js should be after your other scripts.

关于ruby-on-rails - 使用 Turbolinks 和 jQuery Turbolinks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22937946/

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