同位素:重置所有组合过滤器 [英] Isotope: reset all combination filters

查看:116
本文介绍了同位素:重置所有组合过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个同位素组合过滤器设置,其中包含多个数据过滤器组,每个都有一个rest/显示所有列表项:

I have an isotope combination filter setup with a number of data-filter-group's, each with a rest/show all list item:

<li><a href="#" data-filter="*">Show all</a></li>

是否可以重置所有数据过滤器组的重置所有"链接?

Is a way to reset all the data-filter-group's - a 'reset-all' link?

我当前的JavaScript是:

My current javascript is:

        var $container = $('.content ul.sort'),
            filters = {};

        $container.isotope({
          itemSelector : '.dynamic-filter'
        });

        // filter buttons
        $('.filter a').click(function(){
          var $this = $(this);
          // don't proceed if already selected
          if ( $this.hasClass('selected') ) {
            return;
          }

          var $optionSet = $this.parents('.option-set');
          // change selected class
          $optionSet.find('.selected').removeClass('selected');
          $this.addClass('selected');

          // store filter value in object
          // i.e. filters.color = 'red'
          var group = $optionSet.attr('data-filter-group');
          filters[ group ] = $this.attr('data-filter-value');
          // convert object into array
          var isoFilters = [];
          for ( var prop in filters ) {
            isoFilters.push( filters[ prop ] )
          }
          var selector = isoFilters.join('');
          $container.isotope({ filter: selector });

          return false;
        });

有什么主意吗?

<-编辑->

似乎找到了我自己问题的答案:

Appear to have found an answer to my own question:

        $(".isotope-reset").click(function(){
        $(".content ul.sort").isotope({
            filter: '*'
        });
    });

推荐答案

由于发帖人没有将他的答案写在答案中,所以这是给那些想知道这个问题却没有看到答案的人的

As the poster didn't put his answer in an answer, here it is for people who get to this question and don't see that there's an answer

以下代码重置isotop过滤器:

Following code resets isotop filter:

$(".isotope-reset").click(function(){
    $(".content ul.sort").isotope({
        filter: '*'
    });
});

这篇关于同位素:重置所有组合过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆