I have a function that I'm testing, it is supposed to check all table headers to see if it has a particular class, remove it and replace it with another class. I'm using this to switch metadata parsers for the tablesorter plugin. The code I have so far is below:
$(function(){
$("th").each(function(){
if ($(this).hasClass("{sorter: 'usLongDate'}")) {
$(this).removeClass("{sorter: 'usLongDate'}").addClass("{sorter: 'false'}");
}
});
});
$(function() {
$("table").tablesorter({});
});
I'm trying to switch the class parser in the following header to the false inline parser.
<th class="{sorter: 'usLongDate'}"><a rel = "Header" href="#" title="Sort column in decending order" class="">Date</a></th>
Of course this isn't my only header, I'm just testing it on this one, I'm assuming the rest of the headers shouldn't be affected, tablesorter should still be sorting those. But when I run the html file, nothing works. Is there something I'm missing?? Thanks.
NOTE: Just to avoid confusion, the tablesorter plugin for jQuery can use inline parsers within the class attribute of a table header in order to determine how and/or whether a column should be sorted.
UPDATE: Tried Vincent Robert's suggestion, unfortunately it doesn't work. In regards to whether or not addClass and removeClass can handle these. I have an original function that was able to add the disable parser to all classes,
$("th[class='']").addClass("{sorter: 'false'}");
this comes from Paolo Bergantino, and it worked great. I'm just trying to extend it a bit.