62,046
社区成员
发帖
与我相关
我的任务
分享
var c = $('#newslist').children().size();
$('#newslist').scrollPagination({
'contentPage': '/home/ajaxhomelist', // the url you are fetching the results
'contentData': { pageSize: 5, count: c }, // these are the variables you can pass to the request, for example: children().size() to know which page you are
'scrollTarget': $(window), // who gonna scroll? in this example, the full window
'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
'beforeLoad': function () { // before load function, you can display a preloader div
$('#loading').fadeIn();
},
'afterLoad': function (elementsLoaded) { // after loading content, you can use this function to animate your new elements
$('#loading').fadeOut();
c = c + 5;
this.contentData.count = c;
$(elementsLoaded).fadeInWithDelay();
if ($('#newslist').children().size() > 30 || $(elementsLoaded).length == 0) { // if more than 100 results already loaded, then stop pagination (only for testing)
$('#nomoreresults').fadeIn();
$('#newslist').stopScrollPagination();
}
}
});