0
votes

I'm trying to use fancybox so that my pics can be viewed nicely. I have the same issue as Fancy box making image disappear on rails, but even after adding the href to my link it does not work.

The issue is when I click on the pic, the fancybox image viewer pops up, but the image on my site disappears.

Here's the part of my code that doesn't work:

<% if @album.photos.any? %>
    <% @album.photos.each do |photo| %>
        <div class="picthumb">
            <%= link_to image_tag(photo.avatar.url(:small), :class => "fancybox"), "#" %>
        </div>
    <% end %> 
<% else %>
    There are no pics in this album
<% end %>

Anyone know what's going on?

1

1 Answers

2
votes

So I eventually figured it out. It's cuz I was using fancybox on the image as opposed to the link.

<% if @album.photos.any? %>
    <% @album.photos.each do |photo| %>
        <div class="picthumb">
            <%= link_to image_tag(photo.avatar.url(:small)), photo.avatar.url , :class => "fancybox" %>
        </div>
    <% end %> 
<% else %>
    There are no pics in this album
<% end %>

that's the new html.

$(document).ready(function() {
#before, I had img.fancybox in the element selector instead of a.fancybox
$("a.fancybox").fancybox();
});