Backbone-relational
Backbone-relational copied to clipboard
binding views automatically to newly created child models. What am I missing?
After a long struggle I finally located the issue I was having to the fact that on save of the parent-model NEW child models are created.
In my app this means that childviews will be bound to orphaned childmodels once the new child models are created. (Of course) I want my child views to keep referencing the respective newly created model instead.
imho this seems such a common usecase that I hope I must be missing something trivial to keep my childviews bound to the newly created childmodels automatically.
What's the best practice to approach this?
What do you mean by this exactly? Do you have a code snippet? The new child models aren't just created out of thin air I guess?
If the child models are in a collection on the parent model and are created on the server because the parent got saved, maybe findModel is what you're looking for? Just added that last week.
"he new child models aren't just created out of thin air I guess?" Well, it's a been some time so I don't recall exactly, but I believe the creation of the new child models is done by Backbone-Relational upon save of the parentmodel.
Posted a question on SO a month ago which goes into a bit more detail
http://stackoverflow.com/questions/20547088/backbone-relational-save-creates-new-child-models-which-results-in-childviews-b