diff --git a/js/ext/ext.paging.js b/js/ext/ext.paging.js index 085eebd6a..4b1c7877e 100644 --- a/js/ext/ext.paging.js +++ b/js/ext/ext.paging.js @@ -131,7 +131,7 @@ $.extend( true, DataTable.ext.renderer, { case 'last': btnDisplay = lang.sLast; - if ( page === pages-1 ) { + if ( pages === 0 || page === pages-1 ) { tabIndex = -1; btnClass += ' ' + disabledClass; } diff --git a/test/options/Options/pagingType.js b/test/options/Options/pagingType.js index d96148523..f57a1ed74 100644 --- a/test/options/Options/pagingType.js +++ b/test/options/Options/pagingType.js @@ -217,6 +217,62 @@ describe('pageType Option', function() { }); }); + describe('Check the various paging types when empty table', function() { + dt.html('empty'); + it('Default', function() { + $('#example').dataTable(); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Numbers', function() { + $('#example').dataTable({ + pagingType: 'numbers' + }); + expect($('.paginate_button').length).toBe(0); + }); + + dt.html('empty'); + it('Simple', function() { + $('#example').dataTable({ + pagingType: 'simple' + }); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Simple Numbers', function() { + $('#example').dataTable({ + pagingType: 'simple_numbers' + }); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Full', function() { + $('#example').dataTable({ + pagingType: 'full' + }); + expect($('.paginate_button').length).toBe(4); + }); + + dt.html('empty'); + it('Full Numbers', function() { + $('#example').dataTable({ + pagingType: 'full_numbers' + }); + expect($('.paginate_button').length).toBe(4); + }); + + dt.html('empty'); + it('First Last Numbers', function() { + $('#example').dataTable({ + pagingType: 'first_last_numbers' + }); + expect($('.paginate_button').length).toBe(2); + }); + }); + describe('General odds and ends', function() { dt.html('basic'); it('Short page length when mid-table', function() {