absingharora
absingharora

Reputation: 134

colorbox-rails doesn't work work until I refresh the page

I installed colorbox-rails gem for a Rails 4 project. Everything seems to work but only after I refresh the page.

Installation

Code

<%= link_to image_tag(photo.image.url, class: 'img-thumbnail'), photo.image.remote_url, rel: 'gallery', :data => { :colorbox_static => true, colorbox_photo: true}, target: '_blank' %>

Upvotes: 1

Views: 386

Answers (1)

Inkling
Inkling

Reputation: 3782

"Only works on refresh" is a common issue for people using Turbolinks, because it changes which Javascript events get fired on a page change. There's a few things to try, assuming this is the issue:

  • Use the jquery-turbolinks gem.
  • Disable turbolinks for that specific link by adding no_turbolink: true to the data hash.
  • Disable turbolinks for your application altogether.

More information on turbolinks here if you need it.

Upvotes: 1

Related Questions