Search code examples
javascriptjqueryruby-on-rails-4lightboxfancybox-2

Lightbox/Fancybox for Rails 4


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?


Solution

  • Update – I've gone with foundation, a free framework which works well with rails and includes a modal, as well as many other features