added pageSet method

This commit is contained in:
Mottie 2013-02-10 11:47:59 -06:00
parent 9c5823c263
commit 628b79b0f8
2 changed files with 28 additions and 14 deletions

View File

@ -357,9 +357,8 @@
moveToPage = function(table, c) { moveToPage = function(table, c) {
if ( c.isDisabled ) { return; } if ( c.isDisabled ) { return; }
var p = Math.min( c.totalPages, c.filteredPages ); var p = Math.min( c.totalPages, c.filteredPages );
if ( c.page < 0 || c.page > ( p - 1 ) ) { if ( c.page < 0 ) { c.page = 0; }
c.page = 0; if ( c.page > ( p - 1 ) ) { c.page = p - 1; }
}
if (c.ajax) { if (c.ajax) {
getAjax(table, c); getAjax(table, c);
} else if (!c.ajax) { } else if (!c.ajax) {
@ -465,8 +464,8 @@
return; return;
} }
if (e.type === 'filterEnd') { c.page = 0; } if (e.type === 'filterEnd') { c.page = 0; }
updatePageDisplay(table, c);
moveToPage(table, c); moveToPage(table, c);
updatePageDisplay(table, c);
fixHeight(table, c); fixHeight(table, c);
}) })
.bind('disable.pager', function(){ .bind('disable.pager', function(){
@ -485,6 +484,11 @@
c.size = parseInt(v, 10) || 10; c.size = parseInt(v, 10) || 10;
hideRows(table, c); hideRows(table, c);
updatePageDisplay(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 // clicked controls

View File

@ -22,7 +22,7 @@
$("#tablesorter-demo").tablesorter({theme:'blue',sortList:[[0,0],[2,1]],widgets:['zebra'],widthFixed:true}); $("#tablesorter-demo").tablesorter({theme:'blue',sortList:[[0,0],[2,1]],widgets:['zebra'],widthFixed:true});
$(".compatibility").tablesorter({theme:'blue',sortList:[[0,0]],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}); $("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});
}); });
</script> </script>
</head> </head>
@ -1306,7 +1306,7 @@ $(function(){
</tbody> </tbody>
<!-- non-sorting tbody --> <!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly"> <tbody id="deprecated" class="tablesorter-infoOnly">
<tr><th colspan="5">Deprecated Options</th></tr> <tr><th colspan="5">Deprecated Options</th></tr>
</tbody> </tbody>
@ -2045,7 +2045,7 @@ $.extend($.tablesorter.themes.jui, {
</tbody> </tbody>
</table> </table>
<a id="Methods"></a> <a id="methods"></a>
<h1>Methods</h1> <h1>Methods</h1>
<div class="tip"> <div class="tip">
@ -2055,7 +2055,7 @@ $.extend($.tablesorter.themes.jui, {
<em>TIP!</em> Click on the link in the method column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location. <em>TIP!</em> Click on the link in the method column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div> </div>
<table id="methods" class="tablesorter"> <table id="method" class="tablesorter">
<thead> <thead>
<tr> <tr>
<th>Method</th> <th>Method</th>
@ -2262,7 +2262,7 @@ $.tablesorter.refreshWidgets(table, doAll, dontapply)</pre>
</tbody> </tbody>
<!-- non-sorting tbody --> <!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly"> <tbody id="methods-widgets" class="tablesorter-infoOnly">
<tr><th colspan="5">Widget Methods</th></tr> <tr><th colspan="5">Widget Methods</th></tr>
</tbody> </tbody>
@ -2288,7 +2288,7 @@ or, directly add the search string to the filter input as follows:<pre class="pr
</tbody> </tbody>
<!-- non-sorting tbody --> <!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly"> <tbody id="methods-pager" class="tablesorter-infoOnly">
<tr><th colspan="5">Pager Methods</th></tr> <tr><th colspan="5">Pager Methods</th></tr>
</tbody> </tbody>
@ -2299,6 +2299,16 @@ or, directly add the search string to the filter input as follows:<pre class="pr
<div class="collapsible"> <div class="collapsible">
<pre class="prettyprint lang-javascript">$(function(){ <pre class="prettyprint lang-javascript">$(function(){
$('table').trigger('pageSize', 15); $('table').trigger('pageSize', 15);
});</pre></div>
</td>
<td></td>
</tr>
<tr id="pageset">
<td><a href="#" class="toggle2">pageSet</a></td>
<td>Trigger the pager to change the current page. <span class="tip"><em>New!</em></span> v2.7.7.
<div class="collapsible">
<pre class="prettyprint lang-javascript">$(function(){
$('table').trigger('pageSet', 3);
});</pre></div> });</pre></div>
</td> </td>
<td></td> <td></td>
@ -2307,7 +2317,7 @@ or, directly add the search string to the filter input as follows:<pre class="pr
</table> </table>
<a id="Events"></a> <a id="events"></a>
<h1>Events</h1> <h1>Events</h1>
<div class="tip"> <div class="tip">
@ -2317,7 +2327,7 @@ or, directly add the search string to the filter input as follows:<pre class="pr
<em>TIP!</em> Click on the link in the event column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location. <em>TIP!</em> Click on the link in the event column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
</div> </div>
<table id="events" class="tablesorter"> <table id="event" class="tablesorter">
<thead> <thead>
<tr> <tr>
<th>Event</th> <th>Event</th>
@ -2437,7 +2447,7 @@ or, directly add the search string to the filter input as follows:<pre class="pr
</tbody> </tbody>
<!-- non-sorting tbody --> <!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly"> <tbody id="events-pager" class="tablesorter-infoOnly">
<tr><th colspan="5">Pager Events</th></tr> <tr><th colspan="5">Pager Events</th></tr>
</tbody> </tbody>
@ -2581,7 +2591,7 @@ or, directly add the search string to the filter input as follows:<pre class="pr
<!-- non-sorting tbody --> <!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly"> <tbody id="events-widgets" class="tablesorter-infoOnly">
<tr><th colspan="5">Widget Events</th></tr> <tr><th colspan="5">Widget Events</th></tr>
</tbody> </tbody>