2012-01-04 79 views
0

滾動jQuery插件。一切正常,但我無法理解ceaseFire選項。如何使用帶有無盡滾動jQuery插件的ceaseFire

我想在10次後停止回調。

$(document).endlessScroll({ 
    fireOnce: true, 
    fireDelay: 3000, 
    bottomPixels: 750, 
    insertAfter: "ul#articlePagedList li:last", 
    loader: "<div id='processing'><img src='${pageContext.request.contextPath}/images/buttons/icon_busy.gif' alt='<spring:message code='commonMessages.loading' />' /></div>", 
    callback: function(i) { 
     getArticlesEndlessScroll('articlePagedList' ,'${articleListUrl}', i); 
    } 
}); 

我try'ed加入這一點,但它好好嘗試工作...沒有錯誤...

ceasFire: function(i) { if (i==10) return true; } 

回答

1

ceaseFire回調不接收任何參數。請參閱source code for the endless-scroll plugin here。所以在你的函數中,i可能是未定義的。

此外,它可能只是一個錯字,但請確保您在ceaseFire中包含第二個e

例子:

var noneLeft = false; 

$(".scroller").endlessScroll({ 
    callback: function() { 
     $.getJSON("load_more", function(items){ 
      noneLeft &= items.count > 0; 

      ...add items to page... 
     }); 
    }, 
    ceaseFire: function() { 
     return noneLeft; 
    } 
}); 
+0

你能給使用停火正確的方式? – JeroenVdb 2012-02-22 12:51:48