7

同位元素を検索する jquery 検索プラグインを統合しました。このプラグインは、正規表現を使用して、検索入力に基づいてコンテンツをリアルタイムで並べ替えます。

同位体元素は自動的に更新されます (ソーシャル ネットワークからデータを取得する wordpress プラグインを使用しています)

私の質問は、検索の実行後に要素を並べ替えるにはどうすればよいですか?

LE : 検索用他のプラグインを使用してこれを解決しました : コードは次のとおりです。

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

2 に答える 2

2

$container を .load に宣言すると、.load 関数だけがそれを認識します

2 つのソリューションでは、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');
});
于 2013-05-26T12:38:10.607 に答える