afeld / backbone-nested

A plugin to make Backbone.js keep track of nested attributes - looking for maintainers! https://github.com/afeld/backbone-nested/issues/157
https://afeld.github.com/backbone-nested/
MIT License
444 stars 83 forks source link

Better support for model.save with partial setting of nested attributes #143

Open ambischof opened 9 years ago

ambischof commented 9 years ago

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.