From 42f363c96f815587b4653249d4e805349c15cb8c Mon Sep 17 00:00:00 2001 From: Mottie Date: Fri, 16 May 2014 13:22:58 -0500 Subject: [PATCH] Add resetToLoadState method --- docs/index.html | 12 ++++++++++++ js/jquery.tablesorter.js | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/index.html b/docs/index.html index 9f8ca36c..7f0831da 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3576,6 +3576,18 @@ This ajaxProcessing function must return an object with "total", "headers" and " Example + + + Use this method reset the table to it's original settings. (v2.16.5). +
+ Using this method will clear out any settings that have changed since the table was initialized (refreshes the entire table); so any sorting or modified widget options will be cleared.
+ However, it will not clear any values that were saved to storage. This method is basically like reloading the page. +
$('table').trigger('resetToLoadState');
+
+ + + + Use this method to initialize a sort while targeting a specific column header (v2.9). diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 7fbef727..de0636fb 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -948,6 +948,14 @@ .bind("destroy" + c.namespace, function(e, c, cb){ e.stopPropagation(); ts.destroy(table, c, cb); + }) + .bind("resetToLoadState" + c.namespace, function(e){ + // restore original settings; this clears out current settings, but does not clear + // values saved to storage. + c = $.extend(true, ts.defaults, c.originalSettings); + table.hasInitialized = false; + // setup the entire table again + ts.setup( table, c ); }); } @@ -957,6 +965,8 @@ var table = this, // merge & extend config options c = $.extend(true, {}, ts.defaults, settings); + // save initial settings + c.originalSettings = settings; // create a table from data (build table widget) if (!table.hasInitialized && ts.buildTable && this.tagName !== 'TABLE') { // return the table (in case the original target is the table's container)