mixitup在页面加载后初始启动时计算可见项目

时间:2016-12-17 10:13:03

标签: javascript jquery sorting mixitup

我正在使用mixitup来对项目进行排序。

按下排序或过滤按钮后,我可以计算可见的项目:

$('#collection').on('mixEnd', function(e, state){
    var countvisible = $("#container> tr[style='']").length;
    console.log('Sorted! ' + countvisible );

    $('#current_count').text(countvisible);
});

我需要的是:在页面加载时计算可见项目数

但是`on(' mixEnd')在页面加载的mixitup初始化期间不会点燃。

怎么做?我可以暂时使用on PageLoad,但这似乎不是一个好习惯。

任何帮助表示感谢。

2 个答案:

答案 0 :(得分:2)

您是否尝试使用可见选择器?

$('#collection').on('mixEnd', function(e, state){
    var countvisible = $("#container> tr[style='']:visible").length;
    console.log('Sorted! ' + countvisible );

    $('#current_count').text(countvisible);
});

答案 1 :(得分:1)

我知道它有点晚了,但如果能有所帮助,我在this codepen找到了答案。

这是一个巨大的,但在你的情况下,你只需要这个:

$('#collection').on('mixEnd', function(e, state) {
    $('#current_count').html(state.totalShow);
});

state.totalShow是关键;)