Hi guys, I new in CanJS but when i read article about Map set function i couldn’t realize the example about merge new value into current value. But when i try run the sample, error is appeared: TypeError: this.info is undefined
Sample from https://canjs.com/docs/can.Map.prototype.define.set.html
(in the end of the page)
Contact = can.Map.extend({
define: {
info: {
set: function(newVal){
this.info.attr(newVal);
return this.info;
}
}
}
})
var alice = new Contact({
info: {name: 'Alice Liddell', email: 'alice@liddell.com'}
});
alice.attr(); // {name: 'Alice Liddell', 'email': 'alice@liddell.com'}
alice.info._cid; // '.map1'
alice.attr('info', {name: 'Allison Wonderland', phone: '888-888-8888'});
alice.attr();
//{
// name: 'Allison Wonderland',
// email: 'alice@liddell.com',
// phone: '888-888-8888'
//}
alice.info._cid; // '.map1'