From 3dc2530301d64049f6b3e399493a1168b376f47b Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 9 Feb 2015 11:20:11 -0700 Subject: [PATCH] Don't unbind all ts tiggers, add tsmath namespace triggers to add and remove instead --- js/widgets/widget-math.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/js/widgets/widget-math.js b/js/widgets/widget-math.js index 5d0ddcb8..3ceb2df3 100644 --- a/js/widgets/widget-math.js +++ b/js/widgets/widget-math.js @@ -390,17 +390,23 @@ }, init : function(table, thisWidget, c, wo){ c.$table - .unbind(events + ' updateComplete.tsmath') - .bind(events, function(e){ + .off('update.tsmath init.tsmath') + .on(events, function(e){ var init = e.type === 'tablesorter-initialized'; if (e.type === 'updateAll') { // redo data-column indexes in case columns were rearranged - ts.computeColumnIndex( c.$table.children('tbody').children() ); + c.$table.trigger('update.tsmath'); } else if (!wo.math_isUpdating || init) { - math.recalculate( table, c, wo, init ); + c.$table.trigger('init.tsmath'); } }) - .bind('updateComplete.tsmath', function(){ + .on('init.tsmath', function(){ + math.recalculate( table, c, wo, init ); + }) + .on('update.tsmath', function(){ + ts.computeColumnIndex( c.$table.children('tbody').children() ); + }) + .on('updateComplete.tsmath', function(){ setTimeout(function(){ wo.math_isUpdating = false; }, 500); @@ -412,9 +418,9 @@ remove: function(table, c, wo, refreshing){ if (refreshing) { return; } $(table) - .unbind(events + ' updateComplete.tsmath') + .unbind('update.tsmath init.tsmath updateComplete.tsmath') .find('[data-' + wo.math_data + ']').empty(); } }); -})(jQuery); \ No newline at end of file +})(jQuery);