【问题标题】:Add a counter to jquery isotope为 jquery isotope 添加一个计数器
【发布时间】:2013-10-02 10:21:47
【问题描述】:

我在一个项目中使用isotope jquery plugin,我想在每个项目上显示一个简单的计数器,给出重新订购后项目本身的位置。

我的意思是首先显示的项目应该显示'1'值,第三个'3',依此类推。

看起来很简单,但是从现在开始,我做不到了。

我什至尝试使用以下代码调用回调函数(完成时触发):

$cont.isotope({
                    sortBy: $(this).attr('data-filter'),
                     sortAscending: eval($(this).attr('data-sort'))
            }, onAnimationFinished );

var onAnimationFinished = function(){

  var cnt = 0;
  $(".feature").each(function (index) {
        cnt++;
        console.log("counter : " + parseInt(cnt));
        $(this).find('div.counter-container > span.legend').append(' ' + parseInt(cnt));
   });

};

但这没有任何效果。显示值仍为初始值。任何想法都会受到欢迎。非常感谢。

【问题讨论】:

    标签: javascript jquery jquery-isotope


    【解决方案1】:

    David DeSandro 在 github 存储库上回答了问题:https://github.com/desandro/isotope/issues/545#issuecomment-25571902

    目前,如果您想获取项目的顺序,可以通过访问 $filteredAtoms 属性来实现。见http://isotope.metafizzy.co/docs/help.html#accessing_the_instance

    感谢他。它适用于此。希望对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2012-11-01
      • 1970-01-01
      • 2019-03-22
      • 2013-12-15
      • 2019-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多