2

我将will_paginategem 与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 ); 
      });
    }
  );

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

感谢每一个帮助!

4

1 回答 1

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)

这可能会帮助你

于 2015-10-21T20:15:48.980 回答