Fancybox:动态更改 data-fancybox-group
我有一个巨大的图像库,带有一个过滤系统,该系统仅突出显示我从过滤器中选择的图像。因此,当我在画廊上设置过滤器时,我会动态更改 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');
}
});
});
I have a huge gallery of images with a filter system that's highlight only images that I choose from the filter. So when a I set a filter on my gallery I change dynamically the data-fancybox-group to make a gallery only between the image that I filter but Fancybox seem to don't like it...
So when i switched the filter when I try to click on a images after a filter change the fancybox dosen't work at all. Anybody have a clue on that?
Thanks!
Here is the code of Fancybox :
$(".fancybox").fancybox({
openEffect : 'fade',
closeEffect : 'fade',
prevEffect : 'fade',
nextEffect : 'fade',
prevSpeed : 'normal',
nextSpeed : 'normal',
arrows : true,
closeBtn : true
});
Here my filter code :
$(".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');
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论