开发者

ExtJS 4 class loading fails

开发者 https://www.devze.com 2023-04-09 03:45 出处:网络
I have code similar to this: Ext.define(\'GG.view.Workbench\', { exte开发者_如何学JAVAnd: \'Ext.container.Viewport\',

I have code similar to this:

Ext.define('GG.view.Workbench', {
    exte开发者_如何学JAVAnd: 'Ext.container.Viewport',
    layout: 'fit',
    items: [
        {
            xtype: 'container',
            layout: 'border',
            items: [
                {
                    region: 'center',
                    items: [
                        Ext.create('GG.view.Foo')
                    ]
                },
                {
                    region: 'south',
                    items: [
                        Ext.create('GG.view.Bar')
                    ]
                }
            ]
        }
    ],

    initComponent: function() {
        this.callParent(arguments);
    }
});

What happens is that the code does not work when the two Ext.create calls are placed there.

This is what I get on Chrome:

Uncaught TypeError: object is not a function
(anonymous function)
Ext.ClassManager.instantiateext-debug.js:6428
(anonymous function)ext-debug.js:2414
(anonymous function)

How am I supposed to use this Ext.create?


You are overnesting and you have to do that within a method that will be executed each time the class is created

Ext.define('GG.view.Workbench', {
    extend: 'Ext.container.Viewport',
    layout: 'border',

    initComponent: function() {
        var me = this;

        Ext.apply(me, {
            items : me.buildItems()
        });

        me.callParent(arguments);
    },

    buildItems: function() {
        return [
            {
                region: 'center',
                items: [
                    Ext.create('GG.view.Foo')
                ]
            },
            {
                region: 'south',
                items: [
                    Ext.create('GG.view.Bar')
                ]
            }
        ];
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消