Super-stupid question, but I can't make it work, how do we call a function from another function within the same Controller
? I use sencha architect.
Here is my controller where I a have a listener and a function, I want to call generateField
function from the listener
Ext.define('Medlemssystem.controller.MemberOrganisationController', {
extend: 'Ext.app.Controller',
views: [
'LocalOrgPanel'
],
onLocalOrganisationInfoAfterRender: function(component, eOpts) {
main_id = component.up('#memberTab').main_id;
component.removeAll();
Ext.Ajax.request({
url: 'OrganizationCustomFieldServlet',
method: 'GET',
dataType: 'json',
params: {
"operation" : "get",
"org_id" : main_id
},
success: function(response) {
var result = Ext.decode(response.responseText);
result.forEach(function(n) {
component.add(generateField(n.customField.name));
});
},
failure: function() {
console.log('woops');
}
});
},
generateField: function(name, type, id, required, description) {
var field = Ext.create("Ext.form.field.Text", {fieldLabel:name});
return field;
},
init: function(application) {
this.control({
"LocalOrgPanel": {
afterrender: this.onLocalOrganisationInfoAfterRender
}
});
}
});
when I call component.add(generateField(n.customField.name));
I get "function not found" error
After onLocalOrganisationInfoAfterRender: function(component, eOpts) {
paste var that = this;
And then component.add(that.generateField(n.customField.name));