super 愚蠢的问题,但我不能让它工作,我们如何从同一个 Controller
中的另一个函数调用一个函数?我使用 sencha 架构师。
这是我的 Controller ,其中有一个监听器和一个函数,我想从监听器调用 generateField
函数
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
}
});
}
});
当我调用 component.add(generateField(n.customField.name));
时出现“找不到函数”错误
最佳答案
onLocalOrganisationInfoAfterRender 之后:函数(组件,eOpts){
粘贴 var that = this;
然后 component.add(that.generateField(n.customField.name));
关于javascript - extJS - 从同一 Controller 中的另一个函数调用一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19961835/