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">
|
<tr id="sortreset-method">
|
||||||
<td><a href="#" class="permalink">sortReset</a></td>
|
<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">
|
<div class="collapsible">
|
||||||
<br>
|
<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)
|
<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>.
|
<span class="label label-warning">*NOTE*</span> Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>.
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -727,7 +727,7 @@
|
|||||||
if (table.isUpdating) {
|
if (table.isUpdating) {
|
||||||
$table.trigger('updateComplete');
|
$table.trigger('updateComplete');
|
||||||
}
|
}
|
||||||
if (typeof callback === "function") {
|
if ($.isFunction(callback)) {
|
||||||
callback($table[0]);
|
callback($table[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,12 +752,15 @@
|
|||||||
// apply easy methods that trigger bound events
|
// apply easy methods that trigger bound events
|
||||||
$table
|
$table
|
||||||
.unbind('sortReset update updateRows updateCell updateAll addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave '.split(' ').join(c.namespace + ' '))
|
.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();
|
e.stopPropagation();
|
||||||
c.sortList = [];
|
c.sortList = [];
|
||||||
setHeadersCss(table);
|
setHeadersCss(table);
|
||||||
multisort(table);
|
multisort(table);
|
||||||
appendToTable(table);
|
appendToTable(table);
|
||||||
|
if ($.isFunction(callback)) {
|
||||||
|
callback(table);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -852,14 +855,14 @@
|
|||||||
$table
|
$table
|
||||||
.trigger("sortEnd", this)
|
.trigger("sortEnd", this)
|
||||||
.trigger('applyWidgets');
|
.trigger('applyWidgets');
|
||||||
if (typeof callback === "function") {
|
if ($.isFunction(callback)) {
|
||||||
callback(table);
|
callback(table);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.bind("appendCache" + c.namespace, function(e, callback, init) {
|
.bind("appendCache" + c.namespace, function(e, callback, init) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
appendToTable(table, init);
|
appendToTable(table, init);
|
||||||
if (typeof callback === "function") {
|
if ($.isFunction(callback)) {
|
||||||
callback(table);
|
callback(table);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -870,7 +873,7 @@
|
|||||||
}
|
}
|
||||||
// rebuild the cache map
|
// rebuild the cache map
|
||||||
buildCache(table);
|
buildCache(table);
|
||||||
if (typeof callback === "function") {
|
if ($.isFunction(callback)) {
|
||||||
callback(table);
|
callback(table);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user