I am using the jquery-turbolinks gem so that
$(document).ready()
gets fired every page load even when rails turbolinks is turned on. I followed the steps on the github page to install the gem, but the gem doesn't seem to be working as expected. Here's what I've done so far:
gem 'jquery-turbolinks'
to my Gemfile and ran bundle install
added //= require jquery.turbolinks
to my javascript manifest file. My manifest file now looks like this:
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require_tree .
//= require turbolinks
$(document).ready(function() {
alert("turbo!");
});
Then I killed and restarted the rails server
I ran a basic rails scaffold to test to see if everything would work, and I only saw the alert pop up when the application initially loads. However, when I navigated from the index action to the show action, I didn't see the alert box pop up.
Does anyone have any ideas I can try?
I believe this problem occurs because some of the key events in turbolinks 5 have changed. I fixed this problem by downloading the compatibility script suggested by turbolinks. You can find the script here just create a compatibility.coffee under 'assets/javascripts'