StaticRow: add staticRow_event option

This commit is contained in:
Mottie 2015-02-09 17:01:27 -06:00
parent 1de9c46e30
commit 624af67ab0
3 changed files with 21 additions and 11 deletions

View File

@ -88,6 +88,10 @@
<h3 id="notes"><a href="#">Notes</a></h3> <h3 id="notes"><a href="#">Notes</a></h3>
<div> <div>
<ul> <ul>
<li>
In <span class="version">v2.19.1</span>, the <code>staticRow_event</code> option was added.
<p></p>
</li>
<li>This widget will only work in tablesorter version 2.8+.</li> <li>This widget will only work in tablesorter version 2.8+.</li>
<li>The widget was modified from <a href="https://github.com/ascii-soup/Tablesorter-Static-Row-Plugin">Tablesorter-Static-Row-Plugin</a> by <a href="https://github.com/ascii-soup">ascii-soup</a> (<a href="https://github.com/ascii-soup/Tablesorter-Static-Row-Plugin/blob/master/LICENSE">MIT license</a>).</li> <li>The widget was modified from <a href="https://github.com/ascii-soup/Tablesorter-Static-Row-Plugin">Tablesorter-Static-Row-Plugin</a> by <a href="https://github.com/ascii-soup">ascii-soup</a> (<a href="https://github.com/ascii-soup/Tablesorter-Static-Row-Plugin/blob/master/LICENSE">MIT license</a>).</li>
<li>It has been updated to work in tables with multiple tbodies, but not within information-only tbodies.</li> <li>It has been updated to work in tables with multiple tbodies, but not within information-only tbodies.</li>
@ -114,6 +118,7 @@
Set a class name to use to lock a row in place, include a period. Set a class name to use to lock a row in place, include a period.
</td> </td>
</tr> </tr>
<tr id="staticrow_data"> <tr id="staticrow_data">
<td><span class="permalink">staticRow_data</span></td> <td><span class="permalink">staticRow_data</span></td>
<td><code>&quot;static-index&quot;</code></td> <td><code>&quot;static-index&quot;</code></td>
@ -122,6 +127,14 @@
</td> </td>
</tr> </tr>
<tr id="staticrow_event">
<td><span class="permalink">staticRow_event</span></td>
<td><code>&quot;staticRowsRefresh&quot;</code></td>
<td>
Set the event that the widget listens for to perform a refresh.
</td>
</tr>
<tr id="staticrow_index"> <tr id="staticrow_index">
<td><a href="#" class="permalink">staticRow_index</a></td> <td><a href="#" class="permalink">staticRow_index</a></td>
<td><code>&quot;row-index&quot;</code></td> <td><code>&quot;row-index&quot;</code></td>

View File

@ -512,7 +512,7 @@
<li><span class="results">&dagger;</span> <a href="example-widget-resizable.html">Resizable Columns widget</a> (v2.0.23.1; <span class="version updated">v2.19.0</span>)</li> <li><span class="results">&dagger;</span> <a href="example-widget-resizable.html">Resizable Columns widget</a> (v2.0.23.1; <span class="version updated">v2.19.0</span>)</li>
<li><span class="results">&dagger;</span> <a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27)</li> <li><span class="results">&dagger;</span> <a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27)</li>
<li><a href="example-widget-scroller.html">Scroller widget</a> (<span class="version">v2.9</span>; <span class="version updated">v2.19.0</span>).</li> <li><a href="example-widget-scroller.html">Scroller widget</a> (<span class="version">v2.9</span>; <span class="version updated">v2.19.0</span>).</li>
<li><a href="example-widget-static-row.html">StaticRow widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.17.3</span>).</li> <li><a href="example-widget-static-row.html">StaticRow widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.1</span>).</li>
<li><span class="results">&dagger;</span> <a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1; <span class="version updated">v2.18.0</span>)</li> <li><span class="results">&dagger;</span> <a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1; <span class="version updated">v2.18.0</span>)</li>
<li><a href="example-widget-css-sticky-header.html">Sticky header (css3) widget</a> (<span class="version">v2.14.2</span>; <span class="version updated">v2.19.0</span>).</li> <li><a href="example-widget-css-sticky-header.html">Sticky header (css3) widget</a> (<span class="version">v2.14.2</span>; <span class="version updated">v2.19.0</span>).</li>
<li><span class="results">&dagger;</span> UITheme widget (<span class="version updated">v2.17.4</span>; <span class="version updated">v2.19.0</span>): <li><span class="results">&dagger;</span> UITheme widget (<span class="version updated">v2.17.4</span>; <span class="version updated">v2.19.0</span>):

View File

@ -1,6 +1,5 @@
/* /* StaticRow widget for jQuery TableSorter 2.0 - updated 2/9/2015 (v2.19.1)
* StaticRow widget for jQuery TableSorter 2.0 * Version 1.2 mod by Rob Garrison (requires tablesorter v2.16+)
* Version 1.2 - modified by Rob Garrison (6/28/2014 for tablesorter v2.16.1-beta+)
* Requires: * Requires:
* jQuery v1.4+ * jQuery v1.4+
* tablesorter plugin, v2.8+, available at http://mottie.github.com/tablesorter/docs/ * tablesorter plugin, v2.8+, available at http://mottie.github.com/tablesorter/docs/
@ -16,9 +15,6 @@
"use strict"; "use strict";
var ts = $.tablesorter, var ts = $.tablesorter,
// events triggered on the table that update this widget
events = $.trim( 'staticRowsRefresh updateComplete '.split(' ').join('.tsstaticrows ') ),
// add/refresh row indexes // add/refresh row indexes
addIndexes = function(table){ addIndexes = function(table){
var $tr, wo, v, indx, rows, var $tr, wo, v, indx, rows,
@ -55,15 +51,16 @@ ts.addWidget({
options: { options: {
staticRow_class : '.static', staticRow_class : '.static',
staticRow_data : 'static-index', staticRow_data : 'static-index',
staticRow_index : 'row-index' staticRow_index : 'row-index',
staticRow_event : 'staticRowsRefresh'
}, },
init: function(table, thisWidget, c, wo){ init: function(table, thisWidget, c, wo){
addIndexes(table); addIndexes(table);
// refresh static rows after updates // refresh static rows after updates
c.$table c.$table
.unbind(events) .unbind( $.trim('updateComplete.tsstaticrows ' + wo.staticRow_event) )
.bind(events, function(){ .bind( $.trim('updateComplete.tsstaticrows ' + wo.staticRow_event), function(){
addIndexes(table); addIndexes(table);
c.$table.trigger('applyWidgets'); c.$table.trigger('applyWidgets');
}); });
@ -116,7 +113,7 @@ ts.addWidget({
}, },
remove : function(table, c, wo){ remove : function(table, c, wo){
c.$table.unbind(events); c.$table.unbind( $.trim('updateComplete.tsstaticrows ' + wo.staticRow_event) );
} }
}); });