You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you set attribute values in a subclass of $.Observe, $.Observe is applied to those values, not the subclass.
var// Subclass $.Observe to add functionalityMyObserve=$.Observe({myMethod: function(){console.log('myMethod');}}),// Create an instance of my subclassmo=newMyObserve({});mo.myMethod();//--> 'myMethod'mo.attr('foo',{foo: {bar: {qux: 'baz'}}});// mo.attr( 'foo' ) is $.Observe not MyObservemo.attr('foo').myMethod();// ERROR
Glancing through can.Observe, it looks like this is an issue in CanJS as well.
The text was updated successfully, but these errors were encountered:
I don't see what's wrong with that. If you have, for example a Person observe you don't want the address to get converted to a Person but you probably want to have observable attributes:
var Person = can.Observe({
getAddress : function() {
return this.attr('address');
}
});
var inst = new Person({
name : 'David'
});
inst.attr('address', {
city : 'Calgary',
country : 'Canada'
});
In the latests CanJS you can use the can.Observe.attributes plugin to convert to the Observe type you need.
While I think your use case is valid, I am not convinced that mine is not. I am essentially talking about making changes to $.Observe before extending it to a domain object.
I am not familiar enough CanJS to know how to implement it using can.Observe.attributes. I am waiting for this issue to be fixed before migrating from jQueryMX.
When you set attribute values in a subclass of
$.Observe
,$.Observe
is applied to those values, not the subclass.Glancing through
can.Observe
, it looks like this is an issue in CanJS as well.The text was updated successfully, but these errors were encountered: