Skip to content

Instantly share code, notes, and snippets.

@yannvery
Created November 21, 2014 16:27
Show Gist options
  • Select an option

  • Save yannvery/80050fa04844c1c77206 to your computer and use it in GitHub Desktop.

Select an option

Save yannvery/80050fa04844c1c77206 to your computer and use it in GitHub Desktop.
Turbolinks and $(document).ready()

Don't forget when you used turbo-links

Coffeescript

ready = ->
  #...your coffeescript goes here...

$(document).ready(ready)
$(document).on('page:load', ready)
# last line listens for page load which is what turbo links will trigger.

Javascript

var ready;
ready = function() {

  /* ...your javascript goes here... */

};
$(document).ready(ready);
$(document).on('page:load', ready);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment