From 8c2f14b8fd1eef5382b5054ec567bea57e2d1e3e Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 2 Aug 2017 00:09:39 -0500 Subject: [PATCH] Core: Add "widgetRemoveEnd" event. Fixes #1430 --- js/jquery.tablesorter.js | 1 + testing/testing.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index d07b4ed0..fb79d7cd 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -2130,6 +2130,7 @@ c.widgetInit[ name[ index ] ] = false; } } + c.$table.triggerHandler( 'widgetRemoveEnd', table ); }, refreshWidgets : function( table, doAll, dontapply ) { diff --git a/testing/testing.js b/testing/testing.js index 1b41822e..3fb0f251 100644 --- a/testing/testing.js +++ b/testing/testing.js @@ -982,13 +982,19 @@ jQuery(function($){ test has widget function ************************************************/ QUnit.test( 'has & remove zebra widget', function(assert) { - assert.expect(3); + var done = assert.async(); + assert.expect(4); c2.widgets = [ 'zebra' ]; - $table2.trigger('applyWidgets'); - assert.equal( ts.hasWidget( table2, 'zebra'), true, 'table has zebra widget (using table element object)' ); - assert.equal( ts.hasWidget( $table2, 'zebra'), true, 'table has zebra widget (using jQuery table object)' ); - ts.removeWidget( table2, 'zebra' ); - assert.equal( zebra() && c2.widgets.length === 0, false, 'zebra removed' ); + $table2.trigger('applyWidgets', function() { + assert.equal( ts.hasWidget( table2, 'zebra'), true, 'table has zebra widget (using table element object)' ); + assert.equal( ts.hasWidget( $table2, 'zebra'), true, 'table has zebra widget (using jQuery table object)' ); + $table2.one( 'widgetRemoveEnd', function() { + assert.ok( true, 'widgetRemoveEnd fired'); + assert.equal( zebra() && c2.widgets.length === 0, false, 'zebra removed' ); + done(); + }); + ts.removeWidget( table2, 'zebra' ); + }); }); /************************************************