Consider the following code:
var table = function () {
return {
_init: function (tableId) {
this.tableId = tableId;
this.table = $("#" + tableId);
},
removeStripes: function() {
this.table.find(".alt").removeClass("alt");
},
addStripes: function () {
this.table.find("tbody tr:even").addClass("alt");
},
resetStripes: function() {
this.removeStripes();
this.addStripes();
},
sort: function (options) {
this.table.tablesorter(options);
this.table.bind("sortEnd", this.resetStripes);
},
}
}
var newTable = new table();
newTable._init("tableId");
var options = {};
newTable.sort(options);
The browser says this.removeStripes called by this.resetStripes, on one of the last lines) is not a function. I guess there is some error with this
, but I can't figure out where it is. Any idea, anyone?