Isotope: reset all combination filters

前端 未结 2 1325
臣服心动
臣服心动 2021-02-05 16:57

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

  • 相关标签:
    2条回答
    • 2021-02-05 17:32

      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


      Following code resets isotop filter:

      $(".isotope-reset").click(function(){
          $(".content ul.sort").isotope({
              filter: '*'
          });
      });
      
      0 讨论(0)
    • 2021-02-05 17:54

      I was looking for something similar, thought I would put the answer on here just in case another searcher came across this question. My problem with the solution the poster mentioned is that for me at least, it didn't do a true reset. I wanted the buttons to reset as well as the filter. Also I was getting a strange bug where after hitting the reset button, my filters weren't acting right.

      The script below solved all my problems (at the date of this answer, lol). Source: https://github.com/metafizzy/isotope/issues/928

        var $anyButtons = $('.filters').find('button[data-filter=""]');
        var $buttons = $('.filters button');
      
        $('.button--reset').on( 'click', function() {
          // reset filters
          filters = {};
          $grid.isotope({ filter: '*' });
          // reset buttons
          $buttons.removeClass('is-checked');
          $anyButtons.addClass('is-checked');
        });
      
      0 讨论(0)
    提交回复
    热议问题