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
Found this in the Rails 4 documentation, similar to DemoZluk's solution but slightly shorter:
$(document).on 'page:change', ->
# Actions to do
OR
$(document).on('page:change', function () {
// Actions to do
});
If you have external scripts that call $(document).ready()
or if you can't be bothered rewriting all your existing JavaScript, then this gem allows you to keep using $(document).ready()
with TurboLinks: https://github.com/kossnocorp/jquery.turbolinks