I am using stupidtable (http://joequery.github.io/Stupid-Table-Plugin/) to add sorting to a table. I use a callback to add an appropriate up or down arrow to show which column has been used for the sort and whether it is ascending or descending.
The original event handler used the code:
table.bind('aftertablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
var th = $(this).find("th");
th.find(".arrow").remove();
var arrow = data.direction === "asc" ? "↑" : "↓";
th.eq(data.column).append('<span class="arrow">' + arrow +'</span>');
});
This works fine when there is only one row of headers, but if there are multiple rows it doesn't because it finds the first header row not the last.
I'm struggling to find out how to find the bottom row, following another thread I tried:
var th = $(this + ' thead tr:last').find("th");
But this gives a syntax error, I guess because I am not using 'this' properly. Can anyone help?
Thanks,
Steph