2

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?

ramblinjan
  • 6,578
  • 3
  • 30
  • 38
Tamás Pap
  • 17,777
  • 15
  • 70
  • 102

1 Answers1

3
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

zerkms
  • 249,484
  • 69
  • 436
  • 539