Reputation: 3210
For example, my defaults is
defaults: { name: '',
properties: {
weight: 0
}
}
I like to assign to the weight property under properties but without using .set. I'd like to do it during instantiation.
Is this correct?
this.model = new MyModel({name: 'Kenny Rogers', properties.weight: 195 })
Upvotes: 0
Views: 44
Reputation: 3210
I used your solution plus the parse was required but I had to include {parse:true} since I was instantiating it.
parse(resp) {
_.extend(resp.properties, this.defaults.properties);
return resp
}
Upvotes: 0
Reputation: 4515
unfortunately it won't work, you have to pass properties as an object. For instance:
this.model = new MyModel({name: 'Kenny Rogers', properties: { weight: 195 })
Upvotes: 1