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
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 thisthis.__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:
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.
The text was updated successfully, but these errors were encountered:
Maybe we try something like Backbone's initialize. Initialize is a noop, a function the developer can write themselves for any custom initialize functionality, and Backbone will use constructor under the hood. So a private method paired with a public, overridable noop for the developer.
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 toinitialize
method).For example, we have new component type:
and then, I want to call it within of overridden method:
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:
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.
The text was updated successfully, but these errors were encountered: