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));//加载数据
}
};