당신의 질문에 답하기 위해, 예를 들어, 동위 원소의 두 인스턴스에서 두 개의 다른 필터를 실행할 수 있습니다. 당신이 시범을 보여주기 위해 바이올린 예제를 만들었습니다.
Fiddle
편집 : 일부 코드 스타일과 jslint 물건 여기
일부 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;
});
});
});
감사합니다, 그 일을! :) –