metafizzy / isotope

:revolving_hearts: Filter & sort magical layouts
https://isotope.metafizzy.co
11.05k stars 1.41k forks source link

Multiple SortBy: does not trigger sort #1638

Closed papyr closed 2 years ago

papyr commented 2 years ago

Hello, I have several sort options Name, School, Level I need help in hooking /correcting the sort for multiple sorts.

Question: Do I need a new/seperate/additional, sortBy: varSortbyA, sortBy: varSortbyBB for each an every sort Anchor tag??, if so how would I set up the various sorts for the href link to find them?

Issue: Every time I click on the button below, href="#sortBy=School"button it doesnt not sore, but it routes/Posts to the Server/to a new index page.. and does not hookup/trigger to the sort functions below - how can I make sure the different buttons connect/bind/trigger to the sort functions below?


HTML Sort Button


<li><a type=button href="#sortBy=original-order" >original-order</a></li> 
...
       <li><a href="#sortBy=name" data-option-value="name">name</a></li>
       <li><a href="#sortBy=School" data-option-value="School">School</a></li>

JS Sort functions Rank.. , inside getSortData

How do I getSortData:to find the sortBy tags?

// init Isotope
var $grid = $('.grid').isotope({
  itemSelector: '.element',
  ...
  getSortData: {   

    // ***  sort by RANK and School Fees
     Rank: '.Rank', '.AdmissionFees'
      Rank:  function( itemElem ) {
       var Rank = $( itemElem ).find('.Rank').text();
       return parseFloat( Rank.replace( /[\(\)]/g, '') );

      // ***     sort by LEVEL
     Level: '.Level parseInt',
       Level: function( itemElem ) {
       var weight = $( itemElem ).find('.Level').text();
       return parseInt( Level) );
    }
  },

Question Is this href="#sortBy=Rank sort wireup correct,?? how do I connect the

I was missing this, but now that I have it, do I need one new sortBy: for each an every sort Anchor tag?? and what else do I need to setup..

 // how do I add the individual sortBy tags so it finds it, 
  sortBy: Rank,
  sortBy: Level,
});
thesublimeobject commented 2 years ago

@papyr — Do you have a more comprehensive test case you could present (contributing guidelines)? I need a fuller picture of what you're trying to do. I think you might be confused about the sorting config, but without seeing some more context I'm not quite sure. Thanks!

papyr commented 2 years ago

@thesublimeobject thanks so much I was able to get the sort to work, I was missing a comma.

Again I appreciate you jumping in 🤗