$(document).ready(function () { var $container = $("#container"); var filters = {}; var $grid = $container.isotope({ itemSelector: ".bot", percentPosition: false }); $(".filter.option a").click(function (e) { var $this = $(this); // cache the clicked link var filterAttr = "data-filter-value"; var filterValue = $this.attr(filterAttr); // cache the filter var $optionSet = $this.parents(".filter.option"); // cache the parent element var group = $optionSet.attr("data-filter-group"); // cache the parent filter group var filterGroup = filters[group]; if (!filterGroup) { filterGroup = filters[group] = []; } var $selectAll = $optionSet.find('a[' + filterAttr + '=""]'); // the 'select all' button in the current group var activeClass = "selected"; // the class for active links var exclClass = "exclusive"; // the class for exclusive groups comboFiltering($this, filters, filterAttr, filterValue, $optionSet, group, $selectAll, activeClass, exclClass); var comboFilter = getComboFilter(filters); $grid.isotope({ filter: comboFilter }); $this.toggleClass(activeClass); e.preventDefault(); }); });