PDA

View Full Version : Calling overriden method in new code



valio
2 Apr 2014, 4:33 AM
I have to use Ext.override to adapt an existing class method of Ext.menu.Menu.
When using Ext.override I would like to call the original method in order to avoid copy-paste.



Ext.override(Ext.menu.Menu, {
canActivateItem: function(item) {
console.log(item);
//copy-paste of original code => bad style
return item && !item.isDisabled() && item.isVisible() && (item.canActivate || item.getXTypes().indexOf('menuitem') < 0);
}
});
//simplified code above; it's not about a simple console.log of course


Is there a simple way to access the original method in order to avoid copy-paste?
I tried return this.callParent(item) and return this.callSuper(item) without any success.
AFAIK these are only applicable for cases with Ext.define?

valio
2 Apr 2014, 8:40 AM
Never mind. I realized that the problem was that I was supposed to call it with return this.callParent(arguments) instead of return this.callParent(item)

The thread can be thus considered Answered