搜索不起作用后同位素重新排序 [英] isotope reorder after search not working

查看:56
本文介绍了搜索不起作用后同位素重新排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've integrated a jquery search plugin to search through isotope elements, the plugin uses regular expression to sort content, in real-time, based on the search input.

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

Isotope elements are updating automatically ( I'm using a wordpress plugin which retrieves data from social networks )

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

My question is, how can I reorder the elements after the search is performed?

LE:我已经通过使用其他插件来解决这个问题搜索
以下是代码:

L.E : I'VE SOLVED THIS BY USING OTHER PLUGIN FOR SEARCHING: Here is the code:

               $(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' });
}
            });
        });


推荐答案

当你将$ container声明为.load时.load函数会看到它

as you declare $container into the .load, only .load function will see it

两个解决方案,你添加var $ container = $();在正常的js中.load和.ready将访问它

two solutions, you add var $container = $(); in the normal js so .load and .ready will access it

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

or you merge all into the .ready function :

$(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');
});

这篇关于搜索不起作用后同位素重新排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆