简体   繁体   中英

Fancybox does not work as expected

Fancybox works fine if I don't click on previous or next button but when I click on previous or next, the group images are not loaded, only the image I can click is loaded

I use jquery.fancybox-1.3.4.js and this is the script that I call

$(document).ready(function() {
  $("a[rel=example_group]").fancybox({
    'transitionIn'  : 'none',
    'transitionOut' : 'none',
    'titlePosition' : 'over',
    'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
      return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    }
  });
});

and it is the code that I call:

<a rel="example_group" href="images/page1-img3.jpg" alt="" /><img alt="" src="images/page1-img3.jpg"/></a>

Given your example, I only see one image that Fancybox would find with your a[rel=example_group] query. Is your example complete?

If you look at fancybox's website the example includes 3 anchor tags, one for each picture in the group:

<a rel="example_group" title="Custom title" href="http://farm3.static.flickr.com/2641/4163443812_df0b200930.jpg">
    <img alt="" src="http://farm3.static.flickr.com/2641/4163443812_df0b200930_m.jpg" />
</a>

<a rel="example_group" title="" href="http://farm3.static.flickr.com/2591/4135665747_3091966c91.jpg">
    <img alt="" src="http://farm3.static.flickr.com/2591/4135665747_3091966c91_m.jpg" />
</a>

<a rel="example_group" title="" href="http://farm3.static.flickr.com/2561/4048285842_90b7e9f8d1.jpg">
    <img alt="" src="http://farm3.static.flickr.com/2561/4048285842_90b7e9f8d1_m.jpg" />
</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM