View Full Version : Call superclass function

16 Aug 2012, 6:54 AM
mostly I'm using "this.callParent()". But what if I want to call another function than the current from the superclass? Do I have to use the ExtJS3 method with e.g. "Ext.ux.Panel.superclass.hide.call(this)"? Or is there another way similar to "callParent()"?
Thanks and best regards,
Tobias Wagener

Tim Toady
16 Aug 2012, 10:39 AM
As far as I know, there isn't a built in function to call the superclass's function excluding 4.0.x when callParent was added. The 4.0 to 4.1 upgrade guide recommends using the way you used in your post. I don't think it would be too difficult to roll your own, but I'm not sure it is worth the effort.

Wow I totally misread your post. I should read things twice before responding. Yes you would have to use superclass if for some reason you didn't want to call the method on the current object. I don't know why you would override the method on the child class if you want to call the parents though. I suppose there is a use case out there.

16 Aug 2012, 11:16 PM
Thanks for your reply. The reason for this is e.g. I override the setValue function of a field. In this override I start an ajax call to check the value against the server data and in the handler function I will finally call the original setValue function. Is the "this.superclass" property everytime available?

Addinally I have created a small function "callParentFn(fn, args)" like this:

callParentFn: function(fn, args) {
var method,
superMethod = (method = this.callParentFn.caller) &&
(method.$previous || (
(method = method.$owner ? method : method.caller) &&
return superMethod.apply(this, args || noArgs);

Will this also work as expected?

Thanks and best regards...