0
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 为真时如何调用停火?

2- 向上滚动时如何停止回调,就像我在上面的代码中使用 if (pageSequence > 1) {} 处理的那样?

4

1 回答 1

0
Use lazyLoadList.zeroResult instead of this.zeroResult

类名很重要,应该用于调用/访问变量和方法

于 2014-03-11T08:45:42.473 回答