will_paginate +无限滚动插件 - 不显示"正在加载"信息

时间:2012-03-20 11:13:13

标签: jquery ruby-on-rails-3 loader will-paginate infinite-scroll

我将will_paginate gem与Infinite Scroll jQuery Plugin结合使用,并且该机制运行良好。 唯一的例外是显示信息消息,何时加载新内容或何时已加载所有数据 - 此消息不会显示。

这是will_paginate gem生成的分页结构:

<div class="pagination">
  <span class="previous_page disabled">&#8592; Previous</span> 
  <em class="current">1</em> 
  <a rel="next" href="/articles?page=2">2</a> 
  <a href="/articles?page=3">3</a> 
  <a href="/articles?page=4">4</a> 
  <a class="next_page" rel="next" href="/articles?page=2">Next &#8594;</a>
</div>

这是Infinite Scroll plugin的设置:

  $container.infinitescroll({
    navSelector  : '.pagination',    // selector for the paged navigation 
    nextSelector : '.pagination a',  // selector for the NEXT link (to page 2)
    itemSelector : '.box-item',     // selector for all items you'll retrieve
    loading: {
        finishedMsg: 'No more pages to load.',
        img: 'http://i.imgur.com/6RMhx.gif'
      }
    },

    function( newElements ) {
      var $newElems = $( newElements ).css({ opacity: 0 });
      $newElems.imagesLoaded(function(){
        $newElems.animate({ opacity: 1 });
        $container.masonry( 'appended', $newElems, true ); 
      });
    }
  );

一切都应该由手册页设置,但我不知道为什么,信息消息和加载器没有加载......

感谢每一个帮助!

1 个答案:

答案 0 :(得分:0)

而不是

    nextSelector : '.pagination a',  // selector for the NEXT link (to page 2)

使用

    nextSelector : '.pagination a[rel="next"]', // selector for the NEXT link (to page 2)

这可能会对你有所帮助