To answer your question, yes it is possible to run two different filters on two instances of isotope. I've created an example fiddle for you to demonstrate.
Fiddle
Edit: Did some code styling and jslint stuff
Here some js:
$(function () {
"use strict";
//Define your containers and option sets
var $container = [$('#container'), $('#container-new')], $optionSets = [$('#options .option-set'), $('#options-new .option-set')];
//Initialize isotope on each container
jQuery.each($container, function (j) {
this.isotope({
itemSelector : '.element'
});
});
//Initialize filter links for each option set
jQuery.each($optionSets, function (index, object) {
var $optionLinks = object.find('a');
$optionLinks.click(function () {
var $this = $(this), $optionSet = $this.parents('.option-set'), options = {},
key = $optionSet.attr('data-option-key'),
value = $this.attr('data-option-value');
// don't proceed if already selected
if ($this.hasClass('selected')) {
return false;
}
$optionSet.find('.selected').removeClass('selected');
$this.addClass('selected');
// make option object dynamically, i.e. { filter: '.my-filter-class' }
// parse 'false' as false boolean
value = value === 'false' ? false : value;
options[key] = value;
if (key === 'layoutMode' && typeof changeLayoutMode === 'function') {
// changes in layout modes need extra logic
changeLayoutMode($this, options);
} else {
// otherwise, apply new options
$container[index].isotope(options);
}
return false;
});
});
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…