开发者

jQuery pagination callback

$("#News-Pagination").pagination(122, {
   items_per_page:20, 
   callback:handlePaginationClick
});

Using this, but on page load handlePaginationClick callback function is called each time au开发者_开发技巧tomatically.

I want that to be only called when user clicks on pagination numbers.


Just don't do anything the first time around:

var afterAnnoyingOnLoad = false;
$("#News-Pagination").pagination(122, {
   items_per_page:20, 
   callback: function () {
       if (afterAnnoyingOnLoad) handlePaginationClick();
       else afterAnnoyingOnLoad = true;
   }
});


...
var isLoading = true;
$("#News-Pagination").pagination(122, {
   items_per_page:20, 
   callback:handlePaginationClick
});
...

function handlePaginationClick(new_page_index, pagination_container) {
    if(isLoading){
        isLoading = false;
        return false;   // avoid running this function on page load
    }
...
...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜