javascriptjquerycanjscanjs-map

CanJS models: attr function and nested data


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?


Solution

  • 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