jquery移动滚动事件到延迟加载内容

时间:2013-01-16 14:17:48

标签: jquery cordova jquery-mobile

是否有推荐的方法在jquery移动应用程序中进行延迟加载/无限滚动内容?如何在单个“页面”上执行此操作?

我应该在页面的页面显示中定义滚动事件功能吗?类似下面的东西?

$( document ).delegate("#a_jquery_page", "pageshow", function() {

    $(window).scroll(function(){
        //check scroll position and load content  
    });
});

或者我应该使用setInterval函数来检查每秒或半秒或其他什么的滚动位置?

1 个答案:

答案 0 :(得分:1)

每次滚动窗口时都会调用.scroll事件,您只需检查此函数中的窗口位置。间隔功能没有理由。

$(window).scroll(function () { 
    var height = $(window).height();
    var scrollTop = $(window).scrollTop();

    if (scrollTop == ....) { <code> }
}