backbone-nested
backbone-nested copied to clipboard
Better support for model.save with partial setting of nested attributes
Lets say we have the following user:
bob = new MyModel({
name: {
first: 'bob',
middle: 'bill',
last: 'smith'
}
})
if you do bob.set({name.first: "Bob"})
you'd get
{
name: {
first: 'Bob',
middle: 'bill',
last: 'smith'
}
}
but if you try to do bob.save({'name.first': "Bob"})
you would get
{
'name.first': 'Bob',
name: {
first: 'bob',
middle: 'bill',
last: 'smith'
}
}
In order to avoid unintended consequences, there should be some mechanism to use save
the same way you would use set
.