jQuery Isotope filtering with Fancybox

家住魔仙堡 提交于 2019-11-27 22:47:59

问题


I made a Website with a Imagegallery, who is able of beeing filtered with jQuery Isotope. You can click on the thumbnails and then cycle trough the images with the fancybox plugin:

Website

Now the thing is, When the Imagegallery is beeing filtered, the fancybox plugin still cycles trough all the images. Even the ones who are not showing up when the filter is applied.

I don't know how I could solve this.

Fancybox determens a gallery with rel="gallery". Isotope determines the filtering effect trough the css class. So if I ad the filtering css class to the rel="" tag (the isotope filtering classes are generated by the cms) I'm no longer able to cycle trough all the images, when everything is displayed.

I really can't get my head around this. Do you have any Idea how to do this?


回答1:


It would help to have some code. However, I can show you how I got fancybox to work with the filtered images.

I'm not using rel=gallery but rather data-fancybox-group=gallery. .fancybox is the class I'm calling fancybox on with the filter string for isotope.

// filter buttons
        $('#filters a').click(function(){
              var selector = $(this).attr('data-filter');
          $('#isotopegallery').isotope({ filter: selector }, function(){
            if(selector == "*"){
             $(".fancybox").attr("data-fancybox-group", "gallery");
            } else{ 
             $(selector).find(".fancybox").attr("data-fancybox-group", selector);
            }
          });
          return false;
        });

It's all in the filter buttons. Share your code if you can't get it to work.




回答2:


I tried doing it the way ellenmva explained, but couldn't get it to work. I ended up removing the $('#isotopegallery').isotope({ filter: selector }, function() part. So what I was left with was:

$('.filterbutton').on("click", function(){
    var selector = $(this).attr('data-option-value');
    if(selector == "*"){
        $(".fancybox").attr("data-fancybox-group", "gallery");
    } else{ 
        $(selector).find(".fancybox").attr("data-fancybox-group", selector);
    }
   return false;
});

That seemed to do the trick, it now works just fine.



来源:https://stackoverflow.com/questions/14414180/jquery-isotope-filtering-with-fancybox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!