Turbolinks conflict with JQuery

Rails 4 incorporates Turbolinks. This “accelerates” page load, usign Ajax calls for content retrieval. Pages load pretty fast… but… JQuery doesn’t load the first time a page loads, it only works after refreshing or on reload.

To solve this, we can use jquery-turbolinks gem. Include it in Gemfile


gem 'jquery-turbolinks'

view raw

Gemfile

hosted with ❤ by GitHub

Then, require it on Javascript application


//= require jquery.turbolinks

view raw

application.js

hosted with ❤ by GitHub

About Franco Cedillo

Hi! I love reggae and flamenco music. I love web technologies and digital industry. Here i am to share some stuff :)
This entry was posted in Ruby on Rails and tagged , . Bookmark the permalink.

Leave a comment