jQuery Isotope - Issue with multiple filters

前端 未结 1 1017
有刺的猬
有刺的猬 2021-01-28 00:16

I try to use multiple filters inside portfolio-like page which uses Isotope.js. Please take a look at this page: http://decart-design.com/avancia-wp/vi-tilbyr/. Single filter wo

相关标签:
1条回答
  • 2021-01-28 01:01

    I've found a way to solve this issue. Here's a proper code:

    jQuery('.filtering li').on('click', 'a', function(e) {
    e.preventDefault();
    
    if ( jQuery(this).parent().hasClass('selected') ) {
     return;
    }
    
    jQuery(this).parent().parent().find('li').removeClass('selected');
    jQuery(this).parent().addClass('selected');
    
    var isoFilters = [];
    var elems = jQuery(this).parents('.filter-wrap').find('li.selected a');
    jQuery.each(elems, function(i, e){
      isoFilters.push(jQuery(e).attr('data-filter'));
    });
    
    var selector = isoFilters.join('');
    var portfolioItems = jQuery(this).parent().parent().parent().parent().find('.filterable-items');
    portfolioItems.isotope({ filter: selector });
    
    console.log(selector);
    
    return false;
    

    });

    Hope this will help someone who stuck with similar problem.

    0 讨论(0)
提交回复
热议问题