このスクリプトはhttp://andersonferminiano.com/jqueryscrollpaginationから入手しました。これは無限のスクローラーであり、気に入っていますが、問題があります。たとえば、私はこのページを持っています。100件の結果を含むdemocontent.html。このスクリプトは、そのページからすべての結果を1回のページネーションで取得し、同じ結果を何度もループします。これにより、ページの読み込みが非常に困難になります。そして、どういうわけか、最初のページ付けで20、2番目のページ付けでさらに20を与え、同じ結果をループさせないようにしたいと思います。出来ますか?関数は次のとおりです。
$(function(){
$('#content').scrollPagination({
'contentPage': 'democontent.html', // the url you are fetching the results
'contentData': {}, // 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();
var i = 0;
$(elementsLoaded).fadeInWithDelay();
if ($('#content').children().size() > 200){ // if more than 100 results already loaded, then stop pagination (only for testing)
$('#nomoreresults').fadeIn();
$('#content').stopScrollPagination();
}
}
});