I have a View and a Model associated with it in backbone. View observe for model changes and change its displaying area accordingly. for example:
var Part = Bacbone.Model.extends({
defaults:{
partId = null,
manufacturer: null,
manufactureDate: null,
type: null
}
});
var PartsCollection = Backbone.Collection.extends({
model:Part;
)};
var Car = Backbone.Model.extends({
defaults:{
carModel: null,
carName: null,
color: null,
partsCollection: null
},
//Overwite the parse method to fill partsCollection
parse: function(response){
// creating partsCollection from response and adding an attribute
// response.partsCollection = new PartsCollection();
retrun response;
}
});
I have a structure similar as shown above. In my design strategy I am changing view content when a model changes.
So now, for example if I am replacing manufacturer 'A' with manufacturer 'B' in 1000 parts out of 5000 parts. This should modify my view and for that I am listening on model change event in my view. Because of 1000 parts modification 1000 change events will get triggered.
Due to manufacturer change I may also want to change 'manufacturerDate' attribute of Part model, and if I change 'manufacturerDate' attr too which in turn will trigger another 1000 events.
Handling these much events in my view might not be a good idea that's what I feel. So can any one can suggest me the way to solve this problem