Tablesorter + Cancel/clear sort on third click
I'm using jquery tablesorter 2.0.5, and would like to be able to have the sort order be removed on the third click (return to initial state)?
Is this possible usi开发者_StackOverflowng tablesorter?
Disclaimer: I've never used this plugin before and this is totally untested but based on the documentation found here. It looks like something like this may work. At least this should help you along.
$(document).ready(function() {
$("table").tablesorter();
$(".headerSortDown, .headerSortUp").live('click', (function() {
num_clicks += 1;
if(num_clicks === 3) {
// set sorting column and direction, this will sort on the [[column, direction]]
$("table").trigger("sorton", [[0,0]]);
num_clicks = 0;
}
});
});
Edit: After reading over your question again I realized that this approach would only work if the data in the first column was already sorted before calling tablesorter(). Check out this answer where the poster suggests to clone the table before ever calling tablesorter(). I think this may be what you're really after.
精彩评论