我已经下载了这个好的插件
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.
更多推荐
发布评论