Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript extJS-从同一控制器中的另一个函数调用函数_Javascript_Extjs4_Extjs4.2_Sencha Architect - Fatal编程技术网

Javascript extJS-从同一控制器中的另一个函数调用函数

Javascript extJS-从同一控制器中的另一个函数调用函数,javascript,extjs4,extjs4.2,sencha-architect,Javascript,Extjs4,Extjs4.2,Sencha Architect,超级愚蠢的问题,但我无法让它工作,我们如何从同一控制器中的另一个函数调用函数?我使用sencha architect 这是我的控制器,我有一个监听器和一个函数,我想从监听器调用generateField函数 Ext.define('Medlemssystem.controller.MemberOrganisationController', { extend: 'Ext.app.Controller', views: [ 'LocalOrgPanel'

超级愚蠢的问题,但我无法让它工作,我们如何从同一
控制器中的另一个函数调用函数?我使用sencha architect

这是我的控制器,我有一个监听器和一个函数,我想从监听器调用
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))在onLocalOrganizationInfoAfterRender:函数(组件,eOpts){

粘贴
var=this;


然后
component.add(即.generateField(n.customField.name));

onLocalOrganizationInfoafterRender:function(component,eOpts){

粘贴
var=this;


然后
component.add(即.generateField(n.customField.name));

另一种方法是为ajax请求回调设置范围

像这样

Ext.Ajax.request({
        url: 'OrganizationCustomFieldServlet',
        method: 'GET',
        dataType: 'json',
        params: {
            "operation" : "get",
            "org_id" : main_id 
        },
        success: function(response) {
           console.log(this); //<-- scope here is Window by default, unless scope is set below
        },
        failure: function() {
            console.log('woops');
        },
        scope :this //<--   Sets the controller as the scope for the success call back

    });
Ext.Ajax.request({
url:“OrganizationCustomFieldServlet”,
方法:“GET”,
数据类型:“json”,
参数:{
“操作”:“获取”,
“组织id”:主组织id
},
成功:功能(响应){

log(this);//另一种方法是为ajax请求回调设置范围

像这样

Ext.Ajax.request({
        url: 'OrganizationCustomFieldServlet',
        method: 'GET',
        dataType: 'json',
        params: {
            "operation" : "get",
            "org_id" : main_id 
        },
        success: function(response) {
           console.log(this); //<-- scope here is Window by default, unless scope is set below
        },
        failure: function() {
            console.log('woops');
        },
        scope :this //<--   Sets the controller as the scope for the success call back

    });
Ext.Ajax.request({
url:“OrganizationCustomFieldServlet”,
方法:“GET”,
数据类型:“json”,
参数:{
“操作”:“获取”,
“组织id”:主组织id
},
成功:功能(响应){

console.log(this);//谢谢你的解释。这也是一个正确的答案,但我会接受sine的答案,因为他之前发布了:-)谢谢你的解释。这也是一个正确的答案,但我会接受sine的答案,因为他之前发布了:-)