jQuery Mobile lazy load list items

限于喜欢 提交于 2020-01-01 03:36:56

问题


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?


回答1:


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

Documentation page here: 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/

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




回答2:


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

Git hub link




回答3:


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

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



来源:https://stackoverflow.com/questions/9786876/jquery-mobile-lazy-load-list-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!