Skip to content Skip to sidebar Skip to footer

Canjs Observable And Dots In Keys

My problem is while using canJS Observable I can't use dots in object keys, because can think that some nesting available here. So let's say if I create new observable: var obs = n

Solution 1:

This was indeed a bug and has been fixed in version 1.1.5. The general rule now is:

var obs = new can.Observe( { "div": {}, "div.test-class": { "color": "#000000;" } } );

Will create the observe you expect. Passing an object to .attr like

obs.attr({ 'my.test': 'testing' });

Will also set my.test as the property. Passing it as a setter like

obs.attr('my.test', 'testing');

Will set { my: { test: 'testing' } }.

Post a Comment for "Canjs Observable And Dots In Keys"