This repository was archived by the owner on Apr 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 319
Null pointer reference when #675
Copy link
Copy link
Open
Description
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;
}
```### Metadata
Metadata
Assignees
Labels
No labels