html5下划手机屏幕,实现数据加载

1首先页面绑定事件   $(window).bind('scroll',scrollbind);

2是否是到了底层需要加载的判断 

 function scrollbind () {


            var newtab= $(".record-tab a").eq(parseInt($('#hidcurrenttab').val()));
            var record=$('.record-list').eq(parseInt($('#hidcurrenttab').val()));
             


            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();
            if(scrollTop + windowHeight < scrollHeight){
                return false;
            }; 


            if (parseInt(newtab.attr('data-page'))>=parseInt(newtab.attr('data-total')) && parseInt( newtab.attr('data-page'))!=0) {
                var record=$('.record-list').eq(parseInt($('#hidcurrenttab').val()));
                if (record.find('li:contains(没有记录了)').length==1) {
                    return false;
                }
                var norecorder='<li style="text-align:center;"><p>没有记录了</p></li>';
                record.find('ul').append(norecorder);
                return false;
            }else{
                getlist((parseInt( newtab.attr('data-page'))+1));//加载数据
            }
        };

猜你喜欢

转载自blog.csdn.net/pengdayong77/article/details/53738457