简体   繁体   English

Jscroll分页插件

[英]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. http://andersonferminiano.com/jqueryscrollpagination/ ,我使用此代码对我的数据库进行调用并显示所有结果。 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. 但是,当您查看democontent.html检索数据的文件democontent.html (他隐藏了文本,您必须查看源代码)时,您将看到它只有17个项目。 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. 如果您会注意到,Anderson告诉插件在加载100个项目后停止,但是他仅在示例中这样做,而不是将此功能写入插件中。

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 . 您可以尝试自己修改他的插件,但是如果您只想更改插件,我建议您使用Paul Irish的Infinite Scroll

You can use mkscroll plugin with is provide you more functionality link for mk scroll is below. 您可以将mkscroll插件与一起使用,为mk滚动提供更多功能的链接如下。

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

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

there are many other option in that. 还有很多其他选择。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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