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包含正确的过滤器名称仍仅为它会隐藏所有其他部分瓷砖这混淆了我。
任何人都可以帮助我。就我的谷歌搜索而言,我们需要设置数据过滤器,并给出与过滤元素的类名相同的值。另外我使用淘汰赛将数据绑定