简体   繁体   中英

Jscroll pagination plugin

i have download this good plugin

http://andersonferminiano.com/jqueryscrollpagination/ and i use this code for do a call to my db and show all the result. The my problem is that i can't stop the showing results when are finish in the database, i wouold like stop the pagination and no repeat the same result. how can i do it? thank you so much

 $(function(){
                    $('#content').scrollPagination({
                        'contentPage': 'democontent.html', // the page where you are searching for results
                        'contentData': {}, // you can pass the children().size() to know where is the pagination
                        'scrollTarget': $(window), // who gonna scroll? in this example, the full window
                        'heightOffset': 10, // how many pixels before reaching end of the page would loading start? positives numbers only please
                        'beforeLoad': function(){ // before load, some function, maybe display a preloader div
                            $('.loading').fadeIn();
                        },
                        'afterLoad': function(elementsLoaded){ // after loading, some function to animate results and hide a preloader div
                             $('.loading').fadeOut();
                             var i = 0;
                             $(elementsLoaded).fadeInWithDelay();
                             if ($('#content').children().size() > 100){ // if more than 100 results loaded stop pagination (only for test)
                                $('#content').stopScrollPagination();
                             }
                        }
                    });

                    // code for fade in element by element with delay
                    $.fn.fadeInWithDelay = function(){
                        var delay = 0;
                        return this.each(function(){
                            $(this).delay(delay).animate({opacity:1}, 200);
                            delay += 100;
                        });
                    };

                });

That plugin actually isn't very good. I'm looking at the plugin's code, and sure enough, it doesn't provide a way to detect when you're at the end of the content.

If you go to the plugin page and scroll down, it appears to be working quite nicely. However, when you look at the file democontent.html (he's hidden the text, you have to view the source) where the data is being retrieved from, you'll see it's only 17 items. But, it keeps loading bogus data as you scroll down.

Not only does the plugin not detect the end of the data, but it also doesn't provide a way of stopping at all. If you'll notice, Anderson told the plugin to stop after 100 items are loaded, but he did this only in his example instead of writing this feature into the plugin.

So, that's why your content isn't stopping. You could try modifying his plugin yourself, but if you'd rather just change plugins, I'd recommend Infinite Scroll, by Paul Irish .

You can use mkscroll plugin with is provide you more functionality link for mk scroll is below.

https://github.com/maulikkanani/Scroll-Pagination

jQuery(window).mkscroll({
         limit:10,              
         total:100,             
     });

there are many other option in that.

如果有任何一个解决此问题的方法是解决方案:一旦“下一页”链接不可用,jscroll将停止加载内容。.因此,请检查何时要停止加载内容,否则“下一页”链接不可用在最后添加的内容中加载。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM