Extjs callback function to controller
extjs, extjs4, extjs4.1, extjs4.2
Solution
You need to pass along the fn and the scope, something like:
Ext.create('Test.libs.Request', {
callback: this.myResponse
scope: this
});
// You need to get a reference to those passed params inside your request method.
Ext.Ajax.request({
url: './handler.php',
method: 'GET',
scope: passedScope,
params: {
data: mydata
},
callback: passedCallback
});
Problem
I have the following base class which handles all request ``` makeRequest: function(mydata) { Ext.Ajax.request({ url: './handler.php', method: 'GET', scope: this, params: { data: mydata }, callback: this.myResponse, success: function(xhr, params) { console.log('Success'); }, failfure: function(xhr, params) { console.log('Failure'); } }); } ``` In my controller I have ``` ............. requires: [ 'Test.libs.Request' ], ............ onItemClick: function() { var objCallback = Ext.create('Test.libs.Request', { scope: this }); objCallback.makeRequest(1); }, myResponse: function(options, success, response) { console.log(response); } ``` After success executes, how can I get to the controller's myResponse as a callback?