javascript jQuery Mobile 延迟加载列表项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9786876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 07:50:17  来源:igfitidea点击:

jQuery Mobile lazy load list items

javascriptjqueryjquery-mobile

提问by Manatok

How do you know that you are at the bottom of a list in jQuery Mobile, I need to lazy load in more results when the end of the list is reached?

您怎么知道您在 jQuery Mobile 中位于列表的底部,当到达列表的末尾时,我需要延迟加载更多结果?

回答by shanabus

There is a working example of using scrollstartand scrollstopevents here, that should get you going in the right direction: http://jsfiddle.net/shanabus/LJTJt/

这里有一个使用scrollstartscrollstop事件的工作示例,它应该让你朝着正确的方向前进:http: //jsfiddle.net/shanabus/LJTJt/

Documentation page here: http://jquerymobile.com/test/docs/api/events.html

文档页面在这里:http: //jquerymobile.com/test/docs/api/events.html

Hope this helps!

希望这可以帮助!

UPDATE

更新

With help from this post, I was able to wire up a better example that does detection against the bottom of the page. If your list view is not in the bottom of the page, this will not work as well. Check the console for some position debug information.

这篇文章的帮助下,我能够构建一个更好的示例,该示例对页面底部进行检测。如果您的列表视图不在页面底部,这将无法正常工作。检查控制台以获取一些位置调试信息。

http://jsfiddle.net/shanabus/LJTJt/1/

http://jsfiddle.net/shanabus/LJTJt/1/

Here it only adds a new item when you reach the bottom of the list.

在这里,它只会在您到达列表底部时添加一个新项目。

回答by Robin C Samuel

Simple code to load more items on reaching page bottom.

在到达页面底部时加载更多项目的简单代码。

 if ($(window).scrollTop() > $('#page1').height() - 500) {
        eventsElement.append('<li><a href="">Stop</a></li>');
        eventsElement.listview('refresh');
 }

For full example,

完整的例子,

see Code here.

请参阅此处的代码

Using jquery-mobile-iscrollview will be better. It provides pull down and pull up events

使用 jquery-mobile-iscrollview 会更好。它提供下拉和上拉事件

Git hub link

Git 中心链接

回答by Samih A

there is a jq mobile plugin names lazyloader that would help .

有一个 jq 移动插件名称lazyloader 会有所帮助。

link :http://dcarrith.github.com/jquery.mobile.lazyloader

链接:http: //dcarrith.github.com/jquery.mobile.lazyloader