I have a quote rotator I use on my homepage. When I load the page from the browser directly (type the address in the browser and hit enter) it works fine.. However, if I cli
I'd guess that this is Turbolinks related. From the fine manual:
Events
With Turbolinks pages will change without a full reload, so you can't rely on
DOMContentLoadedorjQuery.ready()to trigger your code. Instead Turbolinks fires events ondocumentto provide hooks into the lifecycle of the page.
AFAIK, Rails4 enables turbolinks by default (and you have it in your application.js) so $(function() { ... }) won't always fire when changing pages. You could try binding to turbolinks:load instead:
$(document).on('turbolinks:load', function() {
setInterval(rotateQuotes, 5000);
});
You might want to bind to turbolinks:before-visit to clean things up as well.
Alternatively, you could disable Turbolinks if you don't care about it.