Ext.getCmp(..)为null o不是ext-all.js中的对象错误

时间:2013-04-08 14:55:02

标签: javascript internet-explorer extjs

我的应用有问题。我的代码中没有错误,但有时我从extjs库文件(ext-all.js)中得到一个错误,如果我刷新页面就可以了。 错误显示在IE中:

  

Ext.getCmp(..)为null o不是对象/ extjs-all.js第21行char 67494

我的Ajax请求

Ext.Ajax.request({
url: 'script/request.php?operazione=isadmin',
success: function(response){
    var role = response.responseText;
    switch(role){
        case 'admin':
            Ext.getCmp('gestioneUtenti').show();
            Ext.getCmp('ricercaTarga').show();
            break;
        case 'targhe&offerte':
            Ext.getCmp('ricercaTarga').show();
            break;
        case 'targhe':
            Ext.getCmp('ricercaTarga').show();
            break;
    }
}
});

我的代码:

// Definisco viewport
Ext.define('Pollini.view.mainView', {
    extend: 'Ext.container.Viewport',

    layout: {
        pack: 'end',
        type: 'hbox',
        align: 'top'
    },

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'button',
                    text: 'Ricerca targa',
                    id: 'ricercaTarga',
                    width: 155,
                    border: 0,
                    height: 155,
                    margins: 20,
                    handler: function(){
                        window.location = "search.php";
                    },
                    hidden: true,
                    iconCls: 'targaBtn'
                },
                /*{
                    xtype: 'button',
                    text: 'Offerte',
                    id: 'offerte',
                    width: 155,
                    height: 155,
                    margins: 20,
                    handler: function(){
                        window.location = "offerte.php";
                    },
                    hidden: true,
                    iconCls: 'offerteBtn'
                },*/
                {
                    xtype: 'button',
                    text: 'Gestione utenti',
                    id: 'gestioneUtenti',
                    width: 155,
                    height: 155,
                    margins: 20,
                    handler: function(){
                        window.location = "users.php";
                    },
                    hidden: true,
                    iconCls: 'utentiBtn'
                },
                {
                    xtype: 'button',
                    text: 'Logout',
                    width: 155,
                    height: 155,
                    margins: 20,
                    handler: function(){
                        Ext.Ajax.request({
                            url: 'script/request.php?operazione=logout',
                            success: function(){
                                window.location = "index.php";
                            }
                        });
                    },
                    iconCls: 'logoutBtn'
                }
            ]
        });
        this.callParent(arguments);
    }
});

Ext.create('Pollini.view.mainView');

0 个答案:

没有答案