Override error with error

Using Sencha Touch 2.0.0 I'm trying to override class behavior.
I follow these docs and this is a forum post on the topic
But with the following code:

Ext.define('MP.service.Override', {
    extend: 'Ext.Base',
    override: 'Ext.Ajax',

    request: function(cfg) {
        console.log('overriden');
        this.callOverridden(arguments);
    }
});

I get this error in the console:

Uncaught TypeError: Object [object Object] has no method 'override' 

Any help would be greatly appreciated

+3
source share
1 answer

The Ext.Ajax class is one instance of the Ext.data.Connection class, so it cannot be overridden in this way.

You can replace the singleton function, rather than create a “correct” override.

One way would be to do the following:

Ext.Ajax.request = Ext.Function.createInterceptor(Ext.Ajax.request, function(){ 
    console.log('override');
});

, , .

: sencha touch override ext.ajax

0

All Articles