mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Core: applyWidgetId properly accepts jQuery table element
This commit is contained in:
parent
5560f12011
commit
e2d2b472c6
@ -177,12 +177,10 @@
|
||||
// Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
|
||||
var $t = $(this);
|
||||
if (/Destroy/.test( $t.text() )){
|
||||
$table[0].config.widgets = ['zebra'];
|
||||
$table.trigger('destroyPager');
|
||||
$t.text('Restore Pager');
|
||||
} else {
|
||||
$table[0].config.widgets = ['zebra', 'pager'];
|
||||
$table.trigger('applyWidgets');
|
||||
$('table').trigger('applyWidgetId', 'pager');
|
||||
$t.text('Destroy Pager');
|
||||
}
|
||||
return false;
|
||||
@ -233,6 +231,7 @@
|
||||
<em>NOTE!</em>
|
||||
</p>
|
||||
<ul>
|
||||
<li>In <span class="version updated">v2.25.4</span>, updated example to use <code>applyWidgetId</code> to re-apply the pager widget after being destroyed.</li>
|
||||
<li>In <span class="version updated">v2.24.0</span>, a page size select option with a value of "all" will display all rows - not recommended for ajax interactions!</li>
|
||||
<li>In <span class="version">v2.19.0</span>, added <code>pageAndSize</code> method which allows setting both the pager page & size.</li>
|
||||
<li>In <span class="version">v2.17.6</span>, added <code>{startRow:input}</code> and <code>{page:input}</code> variables to the <code>output</code> option.<p></p></li>
|
||||
|
@ -5132,19 +5132,20 @@ $.tablesorter.updateCell( config, $cell, resort, callback );</pre>
|
||||
|
||||
<tr id="applywidgetid">
|
||||
<td><a href="#" class="permalink">applyWidgetId</a></td>
|
||||
<td>Apply the selected widget to the table, but the widget will not continue to be applied after each sort. See the example, it's easier than describing it (<span class="version updated">v2.25.0</span>).
|
||||
<td>Apply the selected widget to the table, but the widget will not continue to be applied after each sort. See the example, it's easier than describing it (<span class="version updated">v2.25.4</span>).
|
||||
<div class="collapsible">
|
||||
<p>In <span class="version updated">v2.25.4</span>, the direct method will now correctly accept <code>$('table')</code>. Previously, only <code>$('table')[0]</code> would work.</p>
|
||||
<p>In <span class="version updated">v2.25.0</span>, this method ensures that the widget initialization code is executed as well as the format function. So now a widget that was not previously initialized or had been previously removed, can be reapplied.</p>
|
||||
<p>Only <em>one</em> widget can be applied at a time using this method.</p>
|
||||
<h4>Direct method:</h4>
|
||||
<pre class="prettyprint lang-js">$.tablesorter.applyWidgetId( $( 'table' ), 'zebra' );</pre>
|
||||
<pre class="prettyprint lang-js">$.tablesorter.applyWidgetId( $('table'), 'zebra' );</pre>
|
||||
<h4>Triggered event method:</h4>
|
||||
<pre class="prettyprint lang-js">$(function(){
|
||||
// initialize tablesorter without the widget
|
||||
$("table").tablesorter();
|
||||
$('table').tablesorter();
|
||||
|
||||
// click a button to apply the zebra striping
|
||||
$("button").click(function(){
|
||||
$('button').click(function(){
|
||||
$('table').trigger('applyWidgetId', 'zebra');
|
||||
return false;
|
||||
});
|
||||
@ -5367,7 +5368,7 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in
|
||||
<pre class="prettyprint lang-js">$(function(){
|
||||
$('table').trigger('destroyPager');
|
||||
});</pre>
|
||||
The only way to restore the pager is to re-initialize the pager addon
|
||||
The only way to restore the pager addon is to re-initialize the pager addon:
|
||||
<br>
|
||||
<pre class="prettyprint lang-js">$(function(){
|
||||
$('table').tablesorterPager(pagerOptions);
|
||||
|
@ -1902,6 +1902,7 @@
|
||||
},
|
||||
|
||||
applyWidgetId : function( table, id, init ) {
|
||||
table = $(table)[0];
|
||||
var applied, time, name,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
|
Loading…
Reference in New Issue
Block a user