0

我以 jQuery Masonry 样式 ( http://masonry.desandro.com/ ) 和 jQuery Quicksearch ( https://github.com/DeuxHuitHuit/quicksearch )显示我的结果。
当我进行搜索时,不匹配的“砖块”会被删除/隐藏 - 这是正确的。但是剩下的匹配的“砖块”散布在页面各处,因为它们被锁定在一个特定的位置。

我知道 Masonry 能够在调整浏览器窗口宽度时重新定位“砖块”,所以我的第一个想法是通过在 Quicksearch -option 中添加一些东西来触发这种效果: -这样:+1px-1pxonAfter

onAfter: function (){
    window.resizeBy(101,0);
}

只是为了检查我是否可以设法更改窗口大小,但这根本不起作用。

有人做过类似的事情吗?
- 或者,有没有办法在事件发生后重新定位砌体 - “砖块”,比如 onkeyUp或其他什么?

4

1 回答 1

0

尝试使用以下内容,它对我有用,除了一件事(下文详述):

jQuery('input#inputfinderid').quicksearch('#content-block .item-to-search',
                {
                'delay': 200,

                'show': function () {
                //show parent of the items found
                    jQuery(this).parent().show();
                },
                'hide': function () {
                //hide parent of the items not found
                    jQuery(this).parent().hide();
                },


                'onAfter': function () {
                    if (jQuery('input#inputfinderid').val()) {
                        //hide parent as you type
                        jQuery(this).parent().parent().hide();

                    } else {
                //show parent as you type
                        jQuery(this).parent().parent().show();
                    }
                    //re-sort masonry objects
                    jQuery('.js-masonry').masonry('layout');                        
                }
            });

我遇到的唯一问题是有时布局无法正确调整,如果我有 3 列,它将创建 3 行,每行 1 列/项目。然而,有时它会在 1 行中正确显示所有 3 个项目。

有人可以帮忙吗?

于 2014-11-07T18:39:36.747 回答