1

我从http://andersonferminiano.com/jqueryscrollpagination获得了这个脚本。它是一个无限滚动器,我喜欢它,但我有一个问题。例如我有这个页面。democontent.html 包含 100 个结果。该脚本只是在一个分页中获取该页面的所有结果,并一次又一次地循环相同的结果,这使我的页面加载非常困难。我希望以某种方式在第一次分页时给我 20 个,在第二个分页中再给我 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();
         }
    }
});
4

0 回答 0