Skip to content

Commit 1423d37

Browse files
committed
sortList fixes to prevent errors. Fix for #92
1 parent bc6a102 commit 1423d37

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

js/jquery.tablesorter.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,9 @@
464464
for (i = 0; i < l; i++) {
465465
s = sortList[i];
466466
o = c.headerList[s[0]];
467-
o.count = s[1] % (c.sortReset ? 3 : 2);
467+
if (o) { // prevents error if sorton array is wrong
468+
o.count = s[1] % (c.sortReset ? 3 : 2);
469+
}
468470
}
469471
}
470472

@@ -785,8 +787,12 @@
785787
})
786788
.bind("sorton", function(e, list, init) {
787789
$(this).trigger("sortStart", this);
788-
// update and store the sortlist
789-
c.sortList = list;
790+
var l = c.headerList.length;
791+
c.sortList = [];
792+
$.each(list, function(i,v){
793+
// make sure column exists
794+
if (v[0] < l) { c.sortList.push(list[i]); }
795+
});
790796
// update header count index
791797
updateHeaderSortCount(this, c.sortList);
792798
// set css for headers

0 commit comments

Comments
 (0)