From f80d3d4c2cf7ea80717e79e456aa9f8c55cebb80 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 4 Nov 2015 19:31:02 -0600 Subject: [PATCH] Core: fix sortRestart preventing sort. Fixes #1072 --- js/jquery.tablesorter.js | 4 ++-- testing/testing.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index a4f7b6ca..7fc895ca 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -1407,8 +1407,8 @@ $header = c.$headers.eq( headerIndx ); // only reset counts on columns that weren't just clicked on and if not included in a multisort if ( $header[ 0 ] !== tmp && - ( notMultiSort || !$header.is( '.' + ts.css.sortDesc + ',.' + ts.css.sortAsc ) ) ) { - c.sortVars[ col ].count = -1; + ( notMultiSort || $header.hasClass( ts.css.sortNone ) ) ) { + c.sortVars[ $header.attr( 'data-column' ) ].count = -1; } } } diff --git a/testing/testing.js b/testing/testing.js index 67f3182a..b7487e6d 100644 --- a/testing/testing.js +++ b/testing/testing.js @@ -632,6 +632,31 @@ jQuery(function($){ }); + QUnit.test( 'sort Restart', function(assert) { + assert.expect(1); + var done = assert.async(); + c1.sortRestart = true; + $.tablesorter.sortReset( c1, function(){ + // 1) click on header one + $table1.one('sortEnd', function(){ + // 2) click on header zero + $table1.one('sortEnd', function(){ + // 3) click on header one, sortRestart should have set it back to ascending sort + // see #1072 + $table1.one('sortEnd', function(){ + assert.equal( c1.$headers[1].className.indexOf( ts.css.sortAsc ) > -1, true ); + c1.sortRestart = false; + done(); + }); + c1.$headers.eq(1).click(); + }); + c1.$headers.eq(0).click(); + }); + c1.$headers.eq(1).click(); + }); + + }); + QUnit.test( 'sort Events', function(assert) { assert.expect(1);