I’m combining Tablesorter’s ‘disable headers using options‘ function and the ‘trigger sortStart / sortEnd‘ function and have run into an issue. The following code works fine for the most part, BUT: when you click on a disabled header, the progress-indicating #overlay div appears and never goes away.
<script type="text/javascript" id="js">
$(document).ready(function() {
// call the tablesorter plugin, the magic happens in the markup
$("#projectTable").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
1: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
2: {
// disable it by setting the property sorter to false
sorter: false
}
}
});
//assign the sortStart event
$("#projectTable").bind("sortStart",function() {
$("#overlay").show();
}).bind("sortEnd",function() {
$("#overlay").hide();
});
}); </script>
Any ideas on how I could fix this so that nothing at all happens when the disabled headers are clicked? Thanks!
EDIT:
This is a solution using some modifications I made to the plugin. The nature of the plugin was such that you can’t know which header was clicked (which seems very strange to me). I’ll post the changes I made if you would like.
EDIT:
Here are the changes I made to the plugin:
Just to give a little background,
sortStartandsortEndare custom events bound to the table. In the plugin, aclickevent is bound to the headers, which in turn triggers thesortStartcustom event on the table. Because of this, there is no reference in the callback to the actual element that received the click.The
sortEndis just triggered a little further down in the same click event for the headers.I don’t know why the author did it this way, but then again, I don’t know why the author used a common word like “header” to denote the header elements. That’s just asking for trouble.
Anyway, here are the fixes. I’m going to give line numbers from the latest unminified version of the plugin.
Step 1:
Around line 520 you’ll see this code where the click is set up for the headers:
…change it to this:
Step 2:
Then a little further down around line 578 you’ll see this code:
…change it to this:
Step 3:
Then go to the
appendToTable()function around line 243 where you’ll see:…change it to:
Step 4:
Finally, in the same
appendToTable()function, around line 285 you’ll see this:…change it to:
Again, I don’t know if there will be any side effects. I sort of doubt it, though. Give it a shot, and let me know how it turned out for you.