From 16d8d2bfe4dda1afe22f557ed07cd43a12f86eb0 Mon Sep 17 00:00:00 2001 From: Khoi Date: Fri, 7 Dec 2012 10:56:34 -0800 Subject: [PATCH] allow first page and last page to be visible so users know how many pages there are --- integration/bootstrap/dataTables.bootstrap.js | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/integration/bootstrap/dataTables.bootstrap.js b/integration/bootstrap/dataTables.bootstrap.js index 4a3caf5..f032125 100644 --- a/integration/bootstrap/dataTables.bootstrap.js +++ b/integration/bootstrap/dataTables.bootstrap.js @@ -73,20 +73,33 @@ $.extend( $.fn.dataTableExt.oPagination, { iEnd = iStart + iListLength - 1; } + var append_page = function(oPaging, an, j) { + sClass = (j==oPaging.iPage+1) ? 'class="active"' : ''; + $('
  • '+j+'
  • ') + .insertBefore( $('li:last', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + }; + for ( i=0, ien=an.length ; i 1 ) { + append_page(oPaging, an, 1); + } // Add the new list items and their event handlers for ( j=iStart ; j<=iEnd ; j++ ) { - sClass = (j==oPaging.iPage+1) ? 'class="active"' : ''; - $('
  • '+j+'
  • ') - .insertBefore( $('li:last', an[i])[0] ) - .bind('click', function (e) { - e.preventDefault(); - oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; - fnDraw( oSettings ); - } ); + append_page(oPaging, an, j); + } + // Append last page + if ( oPaging.iTotalPages > iEnd ) { + append_page(oPaging, an, oPaging.iTotalPages); } // Add / remove disabled classes from the static elements