0

写真をきれいに表示できるように、fancyboxを使用しようとしています。ファンシーボックスで画像がレール上に消えるのと同じ問題がありますが、リンクにhrefを追加しても機能しません。

問題は、写真をクリックすると、fancybox画像ビューアがポップアップしますが、私のサイトの画像が消えることです。

これが私のコードの機能しない部分です:

<% 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 %>

誰が何が起こっているのか知っていますか?

4

1 に答える 1

2

それで私は最終的にそれを理解しました。リンクではなく、画像でfancyboxを使用していたからです。

<% 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 %>

それが新しいhtmlです。

$(document).ready(function() {
#before, I had img.fancybox in the element selector instead of a.fancybox
$("a.fancybox").fancybox();
});
于 2012-10-10T18:39:21.700 に答える