搜索不起作用后同位素重新排序

agi*_*gis 6 search jquery jquery-isotope

我已经集成了一个jquery搜索插件来搜索同位素元素,该插件使用正则表达式根据搜索输入实时对内容进行排序.

同位素元素正在自动更新(我正在使用wordpress插件从社交网络中检索数据)

我的问题是,如何在执行搜索后重新排序元素?

LE:我已经解决了这个通过使用其他插件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' });
}
            });
        });
Run Code Online (Sandbox Code Playgroud)

r04*_*43v 2

当您在 .load 中声明 $container 时,只有 .load 函数会看到它

两种解决方案,您添加 var $container = $(); 在普通的 js 中,.load 和 .ready 将访问它

或者将所有内容合并到 .ready 函数中:

$(function(){
    var $searchBox = $("#searchbox");
    var $searchFilter = $('.searchFilter');
    var $container = $('.wall-outer .stream');

    $searchBox.on("blur",function(){
        if(this.value === '')
                this.value='Keyword(s)';
    }).on("focus",function(){
        if(this.value === this.defaultValue)
                this.value = '';
        else    this.value = null;
    });

    $searchFilter.simpleContentSearch({
        'active' : 'searchBoxActive',
        'normal' : 'searchBoxNormal',
        'searchList' : 'dcwss-content ul li',        // this is important
        'searchItem' : 'div'                        // this is important
    });

    $(".search-btn").on("click", function(){
        $searchBox.val( $(this).data("search") );
        $searchFilter.keyup();
        $container.isotope('reLayout');
    });

    $(".search-reset").on("click", function(){
        $searchBox.val("");
        $searchFilter.keyup();
        $container.isotope('reLayout');
    });             

    $container.isotope('reLayout');
});
Run Code Online (Sandbox Code Playgroud)