issue
In 0.38, when clicking a column header to sort I got this error:
backgrid.js:2489 Uncaught TypeError: Cannot read property 'row' of undefined
at backgrid.js:2489
solution
The issue appears to be in the method refresh which refers to this in a different scope. It's resolvable by keeping a reference to this in the method and referring to that inside the loop. The following method can be patched in:
Backgrid.Body.prototype.refresh =function () {
for (var i = 0; i < this.rows.length; i++) {
this.rows[i].remove();
}
var self = this; // NEW
this.rows = this.collection.map(function (model) {
var row = new self.row({ // CHANGE `this` TO `self`
columns: self.columns, // CHANGE `this` TO `self`
model: model
});
return row;
}, this);
this._unshiftEmptyRowMayBe();
this.render();
this.collection.trigger("backgrid:refresh", this);
return this;
}
```###
issue
In 0.38, when clicking a column header to sort I got this error:
solution
The issue appears to be in the method
refreshwhich refers tothisin a different scope. It's resolvable by keeping a reference tothisin the method and referring to that inside the loop. The following method can be patched in: