I ran into an issue in my Rails 4 app while trying to organize JS files \"the rails way\". They were previously scattered across different views. I organized them into separ
As per the new rails guides, the correct way is to do the following:
$(document).on('turbolinks:load', function() {
console.log('(document).turbolinks:load')
});
or, in coffeescript:
$(document).on "turbolinks:load", ->
alert "page has loaded!"
Do not listen to the event $(document).ready
and only one event will be fired. No surprises, no need to use the jquery.turbolinks gem.
This works with rails 4.2 and above, not only rails 5.