Hello, this is an ongoing project and I'm just about done. I've been developing a custom table sorter based on the tablesorter plugin for jQueryt. It's just about done, thankfully. My last question is this, I have a table header as follows:
<th class="blue_bg"><a rel = "Header" href="#" title="Sort column in decending order" class="">Seats Available</a></th>
I would like to add the inline metadata parser for disabling sorting on a particular column. I currently have a traversing function that goes through each header, without a class, and adds the parser as follows:
//th without a class automatically get sorting disabled
$("th[class='']").each(function(){
$(this).addClass("{sorter: false}");
});
I also have one that goes through and searches for a specific string that indicates whether a column should be disabled from sorting:
//Add disabling parser to each header with a disable class
$("th[class*='csuci.sortable.false']").each(function(){
$(this).removeClass("csuci.sortable.false").addClass("{sorter: false}");
});
Basically, I want it setup so that, unless the user specifies otherwise, by default or by a user defined string, a column will have sorting disabled. So to recap, I have sorting disabled for columns that have no class at all and that have a class that specifies a disable string. I would also like a third condition where a user can have any other class in a header, in this example the user specifies a class to make the background of the column blue. But, I'm not sure what syntax I need to add the disable parser to this example header. Help is appreciated, thanks in advance.
UPDATE: Here is my complete function which adds parsers based on whatt's in, or isn't in, the th class attribute:
$(function(){
//Add disabling parser to each header with a disable class
$("th[class*='csuci.sortable.false']").each(function(){
$(this).removeClass("csuci.sortable.false").addClass("{sorter: false}");
});
//th without a class automatically get sorting disabled
$("th[class='']").each(function(){
$(this).addClass("{sorter: false}");
});
//Add parser to each table that has a class="csuci.sortable."
$("th[class*='csuci.sortable.date']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'usLongDate'}");
});
$("th[class*='csuci.sortable.percent']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'percent'}");
});
$("th[class*='csuci.sortable.ip']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'ip-address'}");
});
$("th[class*='csuci.sortable.url']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'url'}");
});
$("th[class*='csuci.sortable.money']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'currency'}");
});
$("th[class*='csuci.sortable.time']").each(function(){
$(this).removeClass("csuci.sortable.date").addClass("{sorter: 'time'}");
});
});