Thursday, August 15, 2013

ExtJS Unable to override class method

I recently ran into a problem where I could not override a mixin class function.
Ext.define("ContainerMixin", {
    override: "Override.ContainerMixin",
    
    initComponent: function() {
        this.callParent(arguments);
    },
    
    /**
     * @inheritdoc
     * @override
     */
    onWidgetClick: function() {
        alert('override');
    }
});
The strange thing was that initComponent was being overridden correctly. If I set a break point in initComponent, it will always hit the break point, but it was never hitting onWidgetClick method! The problem is that mixins are applied at class-definition time. The solution is to instead override the class that will be using it to use this new mixin.

No comments:

Post a Comment