Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top