KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I develop a jquery & backbone.js web app. One component has an html table and behind this table is a backbone.js collection. Any change in this collection should lead to an update of the html table, so I write this.collection.bind("reset add remove", this.renderRows, this); So I update the html table, when the whole collection gets new, when a new model gets added and when a model gets removed. There's also a detail view component that gets called when the user hovers and clicks over a certain row of the html table. At the beginning of this component I get the right model out of the collection changeModel = this.collection.get(id); After the user has changed some attributes, I do changeModel.set(attrs); and return to the html table. The model in the collection has the correct changed values. But the html table is not updated as none of the 3 events (reset, add, remove) was triggered. So I added "replace" to the collection binding this.collection.bind("replace reset add remove", this.renderRows, this); and before returning from the detail view I called this.collection.trigger("replace"); My solution works, but my question is: Is there any "native" backbone.js solution that is already there and that I have missed and where I do not have to trigger something by myself?
Tags (comma-separated)
Save Edits
Cancel