var lazyLoadList = {
zeroResult:'',
loadList:function(url,templateName,callbackaction,divId){
this.zeroResult = false;
$(document).endlessScroll({
//pagesToKeep: 10,
fireOnce: false,
callback: callbackaction,
ajaxUrl: url,
templateName: templateName,
divIdToUpdate: divId,
ceaseFireOnEmpty:true,
ceaseFire: function(i, p) {
return this.zeroResult;
},
intervalFrequency: 5
});
},
getlist:function(fireSequence, pageSequence, scrollDirection, ajaxUrl, templateName, divIdToUpdate){
if (pageSequence > 1) {
var requestUrl = ajaxUrl + pageSequence;
$.ajax({
url: requestUrl,
dataType: 'json',
complete: function() {
},
success: function(response){
if (response != '0'){
var template = $("#"+templateName).html();
detailView = Mustache.render(template, response.data);
$("#"+divIdToUpdate).append(detailView);
//serviceListTemplateDiv
}else{
this.zeroResult = true;
}
}
});
}
}
};
在上面的代码中我是jQuery无限滚动插件。关于上面的代码我有两个问题: -
1-当this.zeroResult为真时如何调用ceaseFire?
2-如何在向上滚动时停止回调,就像我在上面的代码中使用if(pageSequence> 1){}一样处理了这个问题?
答案 0 :(得分:0)
Use lazyLoadList.zeroResult instead of this.zeroResult
类名很重要,应该用于调用/访问变量和方法