Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

JS isn't firing after the user hits the back button #533

Closed
gregblass opened this issue May 13, 2015 · 2 comments
Closed

JS isn't firing after the user hits the back button #533

gregblass opened this issue May 13, 2015 · 2 comments

Comments

@gregblass
Copy link

After the user hits the back button, none of my JS is firing...all my bootstrap stuff, and also my mobile fly-out menu:

$(function() {
  $("#menu-trigger").click(function() {
    $("body").toggleClass("nav-open");
   });
 });

I have jquery.turbolinks set up correctly as far as I know.

Has anyone else experienced this?

@gregblass
Copy link
Author

Looks like someone has asked this already: #507

And commited a solution here: #509

What if there is no script tag though? My code is in application.js. And what about all the baked in bootstrap code? Popovers, Tooltips, Modals, etc...

@gregblass
Copy link
Author

My solution was to just place your code in a script tag with data-turbolinks-eval=always on the bottom of your application.html.erb, and remove the jQuery onready. Then any js in there is fired even when using back or forward.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant