From 0bf10d9b39431ae5b16b2eaeffd95dbec5d2ea3f Mon Sep 17 00:00:00 2001 From: Leo Zhu Date: Mon, 17 Jun 2013 14:05:48 +0800 Subject: [PATCH 1/2] Button selector should only affect current datatables instance --- pagination/ellipses.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pagination/ellipses.js b/pagination/ellipses.js index 9f3bba3..4247dfe 100644 --- a/pagination/ellipses.js +++ b/pagination/ellipses.js @@ -82,26 +82,28 @@ $.fn.dataTableExt.oPagination.ellipses = { var oClasses = oSettings.oClasses, that = this; + var tableWrapper = oSettings.nTableWrapper; + // Update stateful properties this.fnUpdateState(oSettings); if (oSettings._iCurrentPage === 1) { - $('.' + oClasses.sPageFirst).attr('disabled', true); - $('.' + oClasses.sPagePrevious).attr('disabled', true); + $('.' + oClasses.sPageFirst, tableWrapper).attr('disabled', true); + $('.' + oClasses.sPagePrevious, tableWrapper).attr('disabled', true); } else { - $('.' + oClasses.sPageFirst).removeAttr('disabled'); - $('.' + oClasses.sPagePrevious).removeAttr('disabled'); + $('.' + oClasses.sPageFirst, tableWrapper).removeAttr('disabled'); + $('.' + oClasses.sPagePrevious, tableWrapper).removeAttr('disabled'); } if (oSettings._iCurrentPage === oSettings._iTotalPages) { - $('.' + oClasses.sPageNext).attr('disabled', true); - $('.' + oClasses.sPageLast).attr('disabled', true); + $('.' + oClasses.sPageNext, tableWrapper).attr('disabled', true); + $('.' + oClasses.sPageLast, tableWrapper).attr('disabled', true); } else { - $('.' + oClasses.sPageNext).removeAttr('disabled'); - $('.' + oClasses.sPageLast).removeAttr('disabled'); + $('.' + oClasses.sPageNext, tableWrapper).removeAttr('disabled'); + $('.' + oClasses.sPageLast, tableWrapper).removeAttr('disabled'); } - var i, oNumber, oNumbers = $('.' + oClasses.sPageNumbers); + var i, oNumber, oNumbers = $('.' + oClasses.sPageNumbers, tableWrapper); // Erase oNumbers.html(''); From e285fb42b05629954b6c0e9d5b8895ab9ec544f4 Mon Sep 17 00:00:00 2001 From: Leo Zhu Date: Mon, 17 Jun 2013 14:20:24 +0800 Subject: [PATCH 2/2] if iTotalPage is 0, nextPage and lastPage are also need to be disabled --- pagination/ellipses.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pagination/ellipses.js b/pagination/ellipses.js index 4247dfe..2fa9c8f 100644 --- a/pagination/ellipses.js +++ b/pagination/ellipses.js @@ -95,7 +95,7 @@ $.fn.dataTableExt.oPagination.ellipses = { $('.' + oClasses.sPagePrevious, tableWrapper).removeAttr('disabled'); } - if (oSettings._iCurrentPage === oSettings._iTotalPages) { + if (oSettings._iTotalPages === 0 || oSettings._iCurrentPage === oSettings._iTotalPages) { $('.' + oClasses.sPageNext, tableWrapper).attr('disabled', true); $('.' + oClasses.sPageLast, tableWrapper).attr('disabled', true); } else { @@ -156,4 +156,4 @@ $.fn.dataTableExt.oPagination.ellipses = { _iLastPage: iLastPage }); } -}; \ No newline at end of file +};