From 628b79b0f83adaab092fc105dbc2f52082369e08 Mon Sep 17 00:00:00 2001 From: Mottie Date: Sun, 10 Feb 2013 11:47:59 -0600 Subject: [PATCH] added pageSet method --- addons/pager/jquery.tablesorter.pager.js | 12 ++++++---- docs/index.html | 30 ++++++++++++++++-------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 8d86772f..1ffd65d4 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -357,9 +357,8 @@ moveToPage = function(table, c) { if ( c.isDisabled ) { return; } var p = Math.min( c.totalPages, c.filteredPages ); - if ( c.page < 0 || c.page > ( p - 1 ) ) { - c.page = 0; - } + if ( c.page < 0 ) { c.page = 0; } + if ( c.page > ( p - 1 ) ) { c.page = p - 1; } if (c.ajax) { getAjax(table, c); } else if (!c.ajax) { @@ -465,8 +464,8 @@ return; } if (e.type === 'filterEnd') { c.page = 0; } - updatePageDisplay(table, c); moveToPage(table, c); + updatePageDisplay(table, c); fixHeight(table, c); }) .bind('disable.pager', function(){ @@ -485,6 +484,11 @@ c.size = parseInt(v, 10) || 10; hideRows(table, c); updatePageDisplay(table, c); + }) + .bind('pageSet.pager', function(e,v){ + c.page = (parseInt(v, 10) || 1) - 1; + moveToPage(table, c); + updatePageDisplay(table, c); }); // clicked controls diff --git a/docs/index.html b/docs/index.html index 7d66f504..1388d349 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,7 +22,7 @@ $("#tablesorter-demo").tablesorter({theme:'blue',sortList:[[0,0],[2,1]],widgets:['zebra'],widthFixed:true}); $(".compatibility").tablesorter({theme:'blue',sortList:[[0,0]],widthFixed:true}); $("table.options").tablesorter({theme:'blue',sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}},widgets:['stickyHeaders'],widthFixed:true}); - $("#methods,#events").tablesorter({theme:'blue',sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}},widgets:['stickyHeaders'],widthFixed:true}); + $("#method,#event").tablesorter({theme:'blue',sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}},widgets:['stickyHeaders'],widthFixed:true}); }); @@ -1306,7 +1306,7 @@ $(function(){ - + Deprecated Options @@ -2045,7 +2045,7 @@ $.extend($.tablesorter.themes.jui, { - +

Methods

@@ -2055,7 +2055,7 @@ $.extend($.tablesorter.themes.jui, { TIP! Click on the link in the method column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
- +
@@ -2262,7 +2262,7 @@ $.tablesorter.refreshWidgets(table, doAll, dontapply) - + @@ -2288,7 +2288,7 @@ or, directly add the search string to the filter input as follows:
+		
@@ -2299,6 +2299,16 @@ or, directly add the search string to the filter input as follows:
 						
$(function(){
   $('table').trigger('pageSize', 15);
+});
+ +
+ + + + @@ -2307,7 +2317,7 @@ or, directly add the search string to the filter input as follows:

+	
 	

Events

@@ -2317,7 +2327,7 @@ or, directly add the search string to the filter input as follows:
-
Method
Widget Methods
Pager Methods
pageSetTrigger the pager to change the current page. New! v2.7.7. +
+
$(function(){
+  $('table').trigger('pageSet', 3);
 });
+
@@ -2437,7 +2447,7 @@ or, directly add the search string to the filter input as follows:
+		
@@ -2581,7 +2591,7 @@ or, directly add the search string to the filter input as follows:
+		
Event
Pager Events
Widget Events