我正在使用带有动态数据的无限滚动,但似乎无法超过第 2 页...
当页面最初加载时,我在 URL 中有一个偏移量,所以我们从 0 开始,所以,
test2.html?offset=0
这是加载日期的代码
$offset = $_GET['offset'];
$data = mysql_query("select * from list limit 30 offset $offset;",$db);
echo '<div id="wall" class="transitions-enabled infinite-scroll clearfix">';
while ($databack33 = mysql_fetch_array($data)){
echo '<div class="block">';
echo '<a href=#><img src="'.$databack33[item_pic_url].'"></a>';
echo '</div>';
}
然后加载我使用的下一页:
<nav id="page-nav">
<? $offset = $offset+30; ?>
<a href="test2.html?offset=<?=$offset?>"></a>
</nav>
这适用于第一页和第二页,但它告诉我没有更多的页面可以加载,尽管有更多的数据。
如果我查看页面源代码是正确的test2.html?offset=60
这是砌体/无限滚动设置
<script type="text/javascript">
$(function(){
var $container = $('#wall');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.block',
isAnimated: true,
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
}
});
});
$container.infinitescroll({
navSelector : '#page-nav', // selector for the paged navigation
nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
itemSelector : '.block', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.gif'
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
</script>