In the course 'Practical and Effective JavaScript' (Lynda.com), there's a table highlighting example and a table sorting example.
Here I added the sorting feature to the highlighting table example : http://aorbaroquethrash.com/07_tables/highlight_table.htm
It sorts. The problem is that after sorting, I lost the highlighthing feature.
After sorting, the table is rebuild :
for (i = 0; i < numRows; i++) {
oTBody.appendChild(theSortedRows[i]);
}
What could be done to keep the highlighting feature after sorting?
You need to re-bind the handlers which were a part of your table before. Looks like there is a method called createAutoHiliteTableRows
inside hiliteTables.js
which handles this.
for (i = 0; i < numRows; i++) {
oTBody.appendChild(theSortedRows[i]);
}
createAutoHiliteTableRows(theSortedRows);