-
Notifications
You must be signed in to change notification settings - Fork 255
Description
Hi,
I decide to implement my custom components behavior via components.addType(type, def)
. In fact, as I understood, an object, which I'm passing to this method will be prototype for all components with appropriate type. But there I faced with issue of getting access to prototype methods(super), which I override in my concrete component (in my case it concerns to initialize
method).
For example, we have new component type:
components.addType( "custom", {
initialize: function( opts ){
// some basic initialization
}
......
})
and then, I want to call it within of overridden method:
define({
type: "custom",
initialize: function( opts){
// like this
this.__super__.initialize.call( this, opts );
// or maybe like in "Base2" or "jQuery UI Widget factory"
this._super( opts );
}
})
Of course, JavaScript doesn't support such mechanism for inheritance, but many famous libraries such as Base2 of Dean Edwards and jQuery UI Widget factory implemented workaround for accessing to super methods. In Component.extend()
, which is used for component inheritance, I didn't find such mechanism.
Actually, I have found one way, but it looks awful:
this.constructor.__ super__.constructor.__super__[ "propertyName" ];
Though, we can register callback via components.before()
for this situation. But, I think, it's not really good idea, because this is more common approach and used for all loaded components.
So. Is there some convenient way to resolve it?
Sorry for my bad English :( I hope, I described it correctly.