PDA

View Full Version : Overriding Extjs classes and invoking callParent



silentkid
9 Apr 2013, 1:34 AM
Hi,

I have a few month of experience developing Extjs web application. I ran into this problem :
When I override a class, I modified the method and followed the previous implementation and invoke callParent() . The overriding part works but the callParent() invoked the old implementation.

my overriding code


Ext.override(Ext.layout.component.Draw, {
finishedLayout: function (ownerContext) {


console.log("new layouter being overriden");
this.callParent(arguments);
}
});


The Extjs class method to be overridden:


finishedLayout: function (ownerContext) {
var props = ownerContext.props,
paddingInfo = ownerContext.getPaddingInfo();


console.log("old layouter being overriden");
this.owner.setSurfaceSize(props.contentWidth - paddingInfo.width, props.contentHeight - paddingInfo.height);


this.callParent(arguments);
}


In the console, I can see that first the new layouter prints out the message followed by the old layouter implementation... I put a breakpoint and retrace the invocation stack, the callParent() of the new layouter called the old one. I need to call the parent of the class but not the overridden method.

Any idea how to solve this problem ?

tvanzoelen
9 Apr 2013, 6:18 AM
use callSuper(arguments)

instead