PDA

View Full Version : Extend Ext.Ajax



DmitryF
17 Jul 2012, 7:08 AM
Hello.
Is it possible to extend Ext.Ajax class?
For example:


Ext.define('Ext.Ajax', {
extend: 'Ext.Ajax',
listeners: {
'requestcomplete': function(conn, response){
console.log('Request is completed o_O');
}
},
initComponent: function () {
this.callParent(arguments);
}
});

Tim Toady
17 Jul 2012, 9:00 AM
Ext.Ajax is a singleton instance of Ext.data.Connection. If you want a requestcomplete listener on it, just add it


Ext.Ajax.on( 'requestcomplete', somefunc );


Otherwise, you need to extend Ext.data.Connection (because that is all Ext.Ajax is - check out its source code)
http://docs.sencha.com/ext-js/4-1/source/Ajax.html#Ext-Ajax

DmitryF
17 Jul 2012, 11:55 AM
Thank you! =D>

This works great!


Ext.util.Observable.observe(Ext.data.Connection);
Ext.data.Connection.on('requestexception', function(conn, response) {
if (response.status == 403)
{
... myfunc() ...
}
});