CanJS models: attr function and nested data

904 views Asked by At

In canJS I can set a model property with person.attr('name', 'John Doe');, but sometimes that property contains nested data, so I need to do the following:

var address = person.attr('address');
// Update country
address.country = 'USA'; 
person.attr('address', address);

Is there a shorter solution for this in canJS?

1

There are 1 answers

1
zerkms On BEST ANSWER
person.attr('address.country', 'USA');

http://canjs.us/#why_canjs-flexibility (See the "Engineered limber" section)

PS: I see the canjs for the first time, googled the answer in seconds using "canjs nested objects" request