I am using the code here to sort my table. The code and plugin work great but some of my <td>'s have <input> tags with values corresponding to the user who's row it is. The sorting system will not work will the <input>'s value. Been working on this for awhile and figured I'd ask on here how to get the sorting to look at the input values too.
var table = $('#user-table');
$('.sort-id, .sort-username, .sort-lastname, .sort-firstname')
.wrapInner('<span title="sort this column"/>')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
if( $.text([a]) == $.text([b]) )
return 0;
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
// parentNode is the element we want to move
return this.parentNode;
});
inverse = !inverse;
});
});