How to make Isotope work with multi-filters and sort ascending / descending?

collaboration
tips-and-tricks

#1

I’m trying to create a multi-filter menu of which one drop-down is to sort by most popular to the least popular.
See screencast of Isotope sort ascend / descend issue

When I select “most” and “least” from the drop-down for the FIRST TIME, it works as expected. However, when I go to select “most” for a second time, the sort doesn’t work.

Any ideas what might be causing this?

Here’s my code snippet:

      // On popular selection
      $( '#popular' ).on('change', 'select', function () {
      var $this = $(this);

      // Get the data-category attribute from the selection made
      var $rank = $this.children(':selected').val();

      // Here's where the code breaks when a user selects a drop-down selection after the first time
      if ($rank === 'most') {
      $cards.isotope({sortBy: 'rank'});
      } else {
        $cards.isotope({sortBy: 'rank', sortAscending: false});
      }
    });

Any ideas what might be causing the issue?


#2

Why don’t you go to the English Wordpress.org forum? The people really help you to get out. I myself am no longer for 100% support-seeking there because I went to a forum with lower activity but in my own language.

I fear the worst for you in case you are programming for Wordpress. One of those guys let me rewrite everything in Wordpress programming language and when after weeks I asked for support for the finishing touch he didn’t help me anymore.

The funniest is that when everything was in order with a plugin nobody still registered on my website. Although I’m reworking my website so that in the future maybe they won’t need to register anymore.

Bookmarked.