Jscroll分页插件(Jscroll pagination plugin)

编程入门 行业动态 更新时间:2024-10-21 15:34:27
Jscroll分页插件(Jscroll pagination plugin)

我已经下载了这个好的插件

http://andersonferminiano.com/jqueryscrollpagination/我使用此代码来调用我的数据库并显示所有结果。 我的问题是,当我在数据库中完成时,我无法停止显示结果,我想要停止分页并且不重复相同的结果。 我该怎么做? 非常感谢

$(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; }); }; });

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; }); }; });

最满意答案

那个插件实际上并不是很好。 我正在查看插件的代码,当然,它没有提供一种方法来检测您何时在内容的末尾。

如果你进入插件页面并向下滚动,它似乎工作得非常好。 但是,当您查看文件democontent.html (他隐藏文本,您必须查看源文件)从中检索数据时,您将看到它只有17个项目。 但是,当您向下滚动时,它会不断加载虚假数据。

插件不仅没有检测到数据的结束,而且根本没有提供停止的方法。 如果您注意到,Anderson告诉插件在加载100个项目后停止,但他只在他的示例中执行此操作,而不是将此功能写入插件。

所以,这就是为什么你的内容没有停止。 您可以尝试自己修改他的插件,但如果您只是更换插件,我会推荐Paul Irish的Infinite Scroll

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.

更多推荐

本文发布于:2023-08-01 12:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1358049.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分页   插件   Jscroll   pagination   plugin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!