Isotope: reset all combination filters

Mike picture Mike · Apr 24, 2012 · Viewed 12.1k times · Source

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?

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;
        });

Any idea's?

<-- Edit -->

Appear to have found an answer to my own question:

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

Answer

Kristof Feys picture Kristof Feys · Dec 3, 2013

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: '*'
    });
});