I have backbone nested model:
var ModelA = Backbone.Model.extend({
defaults: {
title: "",
modelB: null
}
});
var ModelB = Backbone.Model.extend({
defaults: {
text: ""
}
});
I want ModelA to save itself everytime ModelB’s member text is changed. How can I do it?
Is it appropriate to assign event listeners inside different model?
How can I unbind those events later?
(I cannot use the Backbone Relational plugin)
This Fiddle shows an example of the binding on
ModelAconstructor. The event binding will be discarded when the instance ofModelBit’s destroyed by the garbage collector.