Fancybox:动态更改data-fancybox-group

时间:2012-02-01 14:47:24

标签: jquery fancybox

我有一个巨大的图像库,其中包含一个过滤系统,该系统仅突出显示我从过滤器中选择的图像。因此,当我在我的图库上设置过滤器时,我会动态更改data-fancybox-group,以便仅在我过滤的图像之间创建一个图库,但Fancybox似乎不喜欢它......

因此,当我在过滤器更换后尝试单击图像时切换过滤器时,fancybox根本不起作用。有人对此有所了解吗?

谢谢!

以下是Fancybox的代码:

$(".fancybox").fancybox({
 openEffect : 'fade',
 closeEffect : 'fade',
 prevEffect : 'fade',
 nextEffect : 'fade',
 prevSpeed : 'normal',
 nextSpeed : 'normal',
 arrows : true,
 closeBtn : true
});

这是我的过滤器代码:

$(".menu-gallery li a").click(function (){

//My filter menu have a id's
var thisID = this.id;

//Loop in the gallery to show or hide the filter image with the selected filter
$(".list-item li div").each(function(){
    if ( $(this).hasClass(thisID) ) {
        $(this).removeClass('hide');
        //Change the data group on the fly to make a gallery only with the selected filter image
        $("a", this).attr('data-fancybox-group',thisID);
    } else {
        $(this).addClass('hide');        
    }

});

});

0 个答案:

没有答案