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
Here's what I have done to ensure things aren't executed twice:
$(document).on("page:change", function() {
// ... init things, just do not bind events ...
$(document).off("page:change");
});
I find using the jquery-turbolinks gem or combining $(document).ready and $(document).on("page:load") or using $(document).on("page:change") by itself behaves unexpectedly--especially if you're in development.