backbone-nested icon indicating copy to clipboard operation
backbone-nested copied to clipboard

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

Open akshaddhoke opened this issue 9 years ago • 0 comments

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/

akshaddhoke avatar Apr 24 '15 01:04 akshaddhoke