Created
February 27, 2014 23:22
-
-
Save jphase/9261845 to your computer and use it in GitHub Desktop.
Add tablesorter parser to sort rows by column class (to easily sort by columns that have icons and such in them)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add custom tablesorter parser | |
$.tablesorter.addParser({ | |
id: 'teams', | |
is: function(s) { | |
return false; | |
}, | |
format: function(s, table, cell) { | |
return $(cell).attr('class') || s; | |
}, | |
type: 'text' | |
}); | |
// Add tablesorters to all tables | |
$('table').each(function(){ | |
switch($(this).attr('id')) { | |
case 'teamlist': | |
// Sort teams tables | |
$(this).tablesorter({ | |
headers: { | |
6: { sorter: 'teams' }, | |
7: { sorter: 'teams' }, | |
8: { sorter: 'teams' }, | |
9: { sorter: 'teams' }, | |
10: { sorter: 'teams' }, | |
11: { sorter: 'teams' }, | |
12: { sorter: 'teams' } | |
} | |
}); | |
break; | |
default: | |
// Sort all other tables | |
$(this).tablesorter(); | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment