I wonder if that would be possible:
During an event I would like to check certain condition, if that condition is true, I would like to cancel the event right away.
In the case below, if this condition is met, I would like to disallow the user of sorting the table at all.
$(table).bind("sortBegin",function(e, table) {
if(condition_is_met){
// ?? How to cancel the sortBegin?
}
});
Is something like this possible in jquery?
Update:
Apologies,
1)I thought tagging tablesorter would be clear enough to indicate which plugin I am using. 😉 Anyway tablesorter it is. Thanks
2) I would like to disallow sorting of any kind until the condition isn’t met anymore. I don’t mind if the whole table would be stopped from sorting or only the current event.
Unfortunately the plugin didn’t think about
preventDefault– you either need to modify it or throw an exception to abort thecall stack, which should be effectively the same as a well supported
preventDefaultbut uglier.IIRC,
.trigger()in jQuery works synchronously, if this is true then this will work.If you want to modify the plugin, this is how you can add support for
preventDefault:Now when the client of the code calls
e.preventDefault()in a sortBegin-event, the plugin would not proceed with sorting.