Fotorama jQuery Gallery with Rails 4.2.0 (Turbolinks issue)
I have a Fotorama jQuery Slider ; however it doesn't work with Turbolinks (and I wouldn't disable Turbolinks).
How can I make this jQuery slider load when the page loaded on it is loaded via Turbolinks?
Q application.js
I have the following code to work with Turbolinks:
var ready;
ready = function() {
// JavaScript to be triggered by Turbolinks/page:load event
};
$(document).ready(ready);
$(document).on('page:load', ready);
Is it possible to add a function to this JavaScript section to load the Fotorama slider?
Any ideas / feedback is appreciated.
Thanks in advance.
+3
Andrew Hendrie
source
to share
2 answers
Yes.
I have never used this slider Fotorama
, but looking at its docs I think you can do it
$(document).on('ready page:load',function(){
$('.fotorama').fotorama();
});
+4
Paritosh piplewar
source
to share
I recommend the jQuery-Turbolinks gem. I use it myself. Just add it to Gemfile, package update and you're good to go.
+1
Elyasin
source
to share