我集成了一个 jquery 搜索插件来搜索同位素元素,该插件使用正则表达式根据搜索输入实时对内容进行排序。
同位素元素会自动更新(我正在使用一个从社交网络检索数据的 WordPress 插件)
我的问题是,执行搜索后如何对元素重新排序?
L.E:我已经通过使用其他插件解决了这个问题 SEARCHING : 这是代码:
$(document).ready(function () {
$("#id_search").quicksearch(".dcsns-content .isotope-item", {
noResults: '#noresults',
loader: 'span.loading',
'show': function () {
$(this).addClass('quicksearch-visible');
},
'hide': function () {
$(this).removeClass('quicksearch-visible');
},
'onAfter': function () {
$('.dcsns-content .stream').isotope({ filter: '.quicksearch-visible' });
}
});
});
最佳答案
通过将以下内容添加到 filtercontent.js 文件的末尾,我能够获得一个一次性示例:
// Get isotope container
$container = jQuery('.dc-wall .stream');
// Clear out existing isotope class instance
$container.data('isotope', null);
// Start a new isotope instance on the container
$container.isotope({ filter: ':visible', sortBy: 'postDate' });
这仅在您第一次单击搜索 1
时有效,但表明重新启动同位素的概念是有效的。我不太了解您的过滤工作原理,但我希望这能为您提供一个起点。
内容过滤器使用 hide()
或 fade()
将项目动画化为 display: none
存在问题,因此这仅当隐藏是即时的时才有效(因此我还更改了过滤器以使用 hide(0)
),例如
jQuery(this).parent('.' + settings.searchList).hide(0);
关于jquery - 搜索不起作用后同位素重新排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16612508/