mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
Add sortReset method callback
This commit is contained in:
parent
872325a458
commit
8d72efd889
@ -3502,12 +3502,18 @@ $("table").trigger("sorton", [sort, callback]);</pre>
|
||||
|
||||
<tr id="sortreset-method">
|
||||
<td><a href="#" class="permalink">sortReset</a></td>
|
||||
<td>Use this method to reset the table to it's initial unsorted state (v2.4.7).
|
||||
<td>Use this method to reset the table to it's initial unsorted state (v2.4.7; <span class="version updated">v2.16.0</span>).
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
This method immediately resets the entire table sort, while the option only resets the column sort after a third click.
|
||||
This method immediately resets the entire table sort, while the option only resets the column sort after a third click.<br>
|
||||
<br>
|
||||
In <span class="version updated">v2.16.0</span>, a callback function was added to this method.<br>
|
||||
<br>
|
||||
<pre class="prettyprint lang-js">// Reset the table (make it unsorted)
|
||||
$("table").trigger("sortReset");</pre>
|
||||
var callback = function(table) {
|
||||
console.log('sort has been reset');
|
||||
};
|
||||
$("table").trigger("sortReset", [callback]);</pre>
|
||||
<span class="label label-warning">*NOTE*</span> Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>.
|
||||
</div>
|
||||
</td>
|
||||
|
@ -727,7 +727,7 @@
|
||||
if (table.isUpdating) {
|
||||
$table.trigger('updateComplete');
|
||||
}
|
||||
if (typeof callback === "function") {
|
||||
if ($.isFunction(callback)) {
|
||||
callback($table[0]);
|
||||
}
|
||||
}
|
||||
@ -752,12 +752,15 @@
|
||||
// apply easy methods that trigger bound events
|
||||
$table
|
||||
.unbind('sortReset update updateRows updateCell updateAll addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave '.split(' ').join(c.namespace + ' '))
|
||||
.bind("sortReset" + c.namespace, function(e){
|
||||
.bind("sortReset" + c.namespace, function(e, callback){
|
||||
e.stopPropagation();
|
||||
c.sortList = [];
|
||||
setHeadersCss(table);
|
||||
multisort(table);
|
||||
appendToTable(table);
|
||||
if ($.isFunction(callback)) {
|
||||
callback(table);
|
||||
}
|
||||
})
|
||||
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
||||
e.stopPropagation();
|
||||
@ -852,14 +855,14 @@
|
||||
$table
|
||||
.trigger("sortEnd", this)
|
||||
.trigger('applyWidgets');
|
||||
if (typeof callback === "function") {
|
||||
if ($.isFunction(callback)) {
|
||||
callback(table);
|
||||
}
|
||||
})
|
||||
.bind("appendCache" + c.namespace, function(e, callback, init) {
|
||||
e.stopPropagation();
|
||||
appendToTable(table, init);
|
||||
if (typeof callback === "function") {
|
||||
if ($.isFunction(callback)) {
|
||||
callback(table);
|
||||
}
|
||||
})
|
||||
@ -870,7 +873,7 @@
|
||||
}
|
||||
// rebuild the cache map
|
||||
buildCache(table);
|
||||
if (typeof callback === "function") {
|
||||
if ($.isFunction(callback)) {
|
||||
callback(table);
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user