大佬教程收集整理的这篇文章主要介绍了寻找一种方法来动态添加更多列表到jQuery Mobile listview的底部,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
//setup an interval so we can throttle the `scroll` event handler since there will be tons of `scroll` events fired var timer = seTinterval(function () { scrollOK = true; },100),//run this every tenth of a second scrollOK = true;//setup flag to check if it's OK to run the event handler $(window).bind('scroll',function () { //check if it's OK to run code if (scrollOK) { //set flag so thE interval has to reset it to run this event handler again scrollOK = false; //check if the user has scrolled within 100px of the bottom of the page if ($(this).scrollTop() + $(this).height() >= ($(document).height() - 100)) { //Now load more list-items because the user is within 100px of the bottom of the page } } });
这是一个演示:http://jsfiddle.net/knuTW/
更新
只需加载一个用户可以点击的按钮,然后在点击它时,加载更多的行,然后将load-more按钮重新附加到列表的末尾,这样会容易一些:
var $loadMore = $('ul').children('.load-more'); $loadMore.bind('click',function () { var out = []; for (var i = 0; i < 10; i++) { out.push('<li>' + (count++) + '</li>'); } $('ul').append(out.join('')).append($loadMorE).listview('refresh'); });
以上是大佬教程为你收集整理的寻找一种方法来动态添加更多列表到jQuery Mobile listview的底部全部内容,希望文章能够帮你解决寻找一种方法来动态添加更多列表到jQuery Mobile listview的底部所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。