1
我想過濾使用MixItUp在AJAX回調方法中動態創建的數據。我有10個部分,每個部分都有一個或多個過濾器。我面臨的問題是,當我點擊一個部分的過濾器時,所有其他部分的數據都被隱藏起來。當我檢查DOM時,覆蓋顯示沒有阻止沒有發生。過濾器值都是唯一的。使用MixItUp過濾動態數據
// The "bindHandlers" method will listen for whenever a button is clicked.
bindHandlers: function() {
var self = this;
self.$filters.on('click', 'a', function (e) {
self.parseFilters();
});
},
parseFilters: function() {
var self = this;
// loop through each filter group and grap the active filter from each one.
for (var i = 0, group; group = self.groups[i]; i++) {
group.active = [];
group.$inputs.each(function() {
if ($(this).find('.selected').length > 0) {
group.active.push($(this).attr('data-filter'));
}
});
}
self.concatenate();
},
concatenate: function() {
var self = this;
self.outputString = ''; // Reset output string
for (var i = 0, group; group = self.groups[i]; i++) {
self.outputString += group.active;
}
// If the output string is empty, show all rather than none:
!self.outputString.length && (self.outputString = 'all');
// Send the output string to MixItUp via the 'filter' method:
if (self.$container.mixItUp('isLoaded')) {
self.$container.mixItUp('filter', self.outputString);
}
}
上面寫的AJAX代碼回調函數和click事件觸發的parseFilter功能,達到連擊和outputString包含正確的過濾器名稱仍僅爲它會隱藏所有其他部分瓷磚這混淆了我。
任何人都可以幫助我。就我的谷歌搜索而言,我們需要設置數據過濾器,並給出與過濾元素的類名相同的值。另外我使用淘汰賽將數據綁定