From 7c5a85c4c28483ad4a51eaf30ad2def4a469b805 Mon Sep 17 00:00:00 2001 From: Mottie Date: Wed, 27 Nov 2013 11:09:30 -0600 Subject: [PATCH] Refreshing widgets now only applies to previously installed widgets. Fixes #442 --- js/jquery.tablesorter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 1111b6b3..e26a367b 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -1284,11 +1284,11 @@ if (init || !(c.widgetInit[w.id])) { if (w.hasOwnProperty('options')) { wo = table.config.widgetOptions = $.extend( true, {}, w.options, wo ); - c.widgetInit[w.id] = true; } if (w.hasOwnProperty('init')) { w.init(table, w, c, wo); } + c.widgetInit[w.id] = true; } if (!init && w.hasOwnProperty('format')) { w.format(table, c, wo, false); @@ -1311,7 +1311,8 @@ for (i = 0; i < l; i++){ if ( w[i] && w[i].id && (doAll || $.inArray( w[i].id, cw ) < 0) ) { if (c.debug) { log( 'Refeshing widgets: Removing ' + w[i].id ); } - if (w[i].hasOwnProperty('remove')) { + // only remove widgets that have been initialized - fixes #442 + if (w[i].hasOwnProperty('remove') && c.widgetInit[w[i].id]) { w[i].remove(table, c, c.widgetOptions); c.widgetInit[w[i].id] = false; }