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
443 stars 83 forks source link

Set() with complex JSON overwrites rather than updating nested attributes #135

Open akshaddhoke opened 9 years ago

akshaddhoke commented 9 years ago

Backbone fetch() uses JSON to set the attributes once they are received, which is causing nested attributes to be overwritten rather than being updated.

I am not sure if this is by design, or a bug, but I was expecting the same behavior whether setting the values using '.' or by directly using a complex JSON. E.g. model.set('name.firstName','John') ----> only updates firstName of nested name attribute model.set({name:{firstName:'John'}}); ----> replaces the nested name attribute

JsFiddle: http://jsfiddle.net/c2yjzs2u/1/