문제

I saw two gems loaded in a Gemfile, so does it makes sense to load both of these gems or use only one?

gem 'jquery-turbolinks'
gem 'turbolinks'

Can anyone tell me why both of the gems are used?

도움이 되었습니까?

해결책

As outlined here jquery-turbolinks gem fixes the bind event that is not always fired due to turbolinks firing ajax requests rather than usual page reloads.

If you have little javascript feel free to drop it but if you have some .bind(...) events that stop working, read the docs for the gem and you can probably use this to fix it, from the documentation:

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top