0

我正在为 extjs/js 和其中的使用而苦苦挣扎this。我正在做的是从 ajax 请求调用 ref,而后者又从 onLaunch() 函数调用,但是 extjs 一直告诉我,没有定义 ref。这是示例代码:

Ext.define('MyController', {
    extend : 'Ext.app.Controller',
    views : ['MyView'],
    refs : [
        {
            selector : '#fieldId',
            ref : 'myUniqueField'
        }
    ],
    onLaunch : function () {
        this.foo();
    },
    foo ; function () {
        Ext.Ajax.request({
            url: myUrl,
            method: 'GET',
            scope: this,
            success : function (response) {  
                 // Here is the problem. getMyUniqueField() is undefiend
                 this.getMyUniqueField().setVisible(false); 
            },

    }
});  

我知道我们需要小心使用它,但在这种特殊情况下,我真的不知道出了什么问题。请你帮助我好吗?谢谢!

我这样定义控制:

Ext.define('MyView', {
    extend : 'Ext.window.Window',
    items : [{
            // useless stuff
                            xtype : 'checkbox',
                            id : 'fieldId',
                            boxLabel : someText
                        }
            //useless stuff
        }
    ],    
});
4

0 回答 0