Ben Belek
Ben Belek

Reputation: 1

Isotope Combination filters Dropdown

I've got an issue with isotope metafizzy filters combination : https://isotope.metafizzy.co/

I'm building a line-up for concerts and meetings. And for example i have a band that plays in London on Wednesday and in Washington on friday.

When I select Town : London / Date : Friday

It also shows me the band in concert in Washington on Friday

Here is my javascript code :


$(window).load(function(){  
    
// init Isotope
var $grid = $('.grid-item').isotope({
    itemSelector: '.item',
    layoutMode: 'fitRows',
});

// store filter for each group
var filters = {};

$('.filters').on( 'change', function( event ) {
  var $select = $( event.target );
  // get group key
  var filterGroup = $select.attr('value-group');
  // set filter for group
  filters[ filterGroup ] = event.target.value;
  // combine filters
  var filterValue = concatValues( filters );
  // set filter for Isotope
  $grid.isotope({ filter: filterValue });
});

// flatten object by concatting values
function concatValues( obj ) {
  var value = '';
  for ( var prop in obj ) {
    value += obj[ prop ];
  }
  return value;
}
})  

Maybe with this fiddle it's more clear : https://jsfiddle.net/9st56qhd/1/

Thanks for your help

Upvotes: 0

Views: 15

Answers (0)

Related Questions