我将will_paginate
gem 与Infinite Scroll jQuery Plugin结合使用,该机制运行良好。唯一的例外是显示信息消息,何时加载新内容或何时已加载所有数据 - 不显示此消息。
will_paginate
这是我由gem生成的分页结构:
<div class="pagination">
<span class="previous_page disabled">← 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 →</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 );
});
}
);
一切都应该由手册页设置,但我不知道为什么,信息消息和加载程序没有加载......
感谢每一个帮助!