Last Updated: February 25, 2016
·
713
· himself

Binding $(document).ready events with Turbolinks

One problem we can get into when using turbolinks is that the binding for $(document).ready gets lost when the page changes location.

To solve this we have to bind the function again, using the page:change event of the window object.

do_on_load = ->
  // function code

$ ->
  do_on_load()

$(window).on('page:change', do_on_load)