Reputation: 2183
I installed a Fancybox2 gem in my rails app, but it's not working 100% of the time. It seems to be an issue with Turbolinks, as it only works after a refresh, or when a page is visited directly.
I already have my jquery set up using:
$(document).ready(ready);
$(document).on('page:load', ready);
where "ready"
is a function, to ensure it works around the Rails 4 turbolinks implementation, but it seems Fancybox has not been updated similarly.
Anyone find any fixes or alternatives out there to get a lightbox working nicely within Rails 4?
I'm thinking there also might be something built into fancybox that I can inside my ready
function to re-initialize when a page loads with turbolinks?
Upvotes: 0
Views: 1059
Reputation: 2059
It's usually an issue with Turboliknks.
To work around this I just reinitialize lightbox everytime turbolinks reloads the page.
Sample in CoffeeScript:
ready = () ->
lightbox.init()
$(document).on 'turbolinks:load', ready
Upvotes: 1
Reputation: 2183
Update – I've gone with foundation, a free framework which works well with rails and includes a modal, as well as many other features
Upvotes: 0