10

I was trying to test out a script i write on firebug console and i think the script is simple enough. And when i ran the script, i got this error me.dockedItems is undefined. Here's the code i run from Firefox's firebug console:

Ext.create('Ext.window.Window',{
    title : 'Login',
    width : 400,
    height : 500,
    initComponent : function() {
        var me = this;

        var usernameField = Ext.create('Ext.form.field.Text',{
            fieldLabel : 'Net ID',
            allowBlank : false,
            labelWidth : 150,
            width : 150,
            emptyText : 'Net ID'
        });

        var passField = Ext.create('Ext.form.field.Text',{
            fieldLabel : 'Password',
            allowBlank : false,
            labelWidth : 150,
            width : 150,
            emptyText : 'Pass'
        });

        this.items = [usernameField,passField];
        this.callParent(arguments);
    }
}).show();

I appreciate your help to find what is wrong with the code

auphali
  • 139
  • 1
  • 8

2 Answers2

14

I got this error when doing

Ext.define('blah', {

    initComponent: function(){
        //do stuff
    }
});

It turns out this question was sortof pointing the right direction but you will also get this mysterious error if you don't call

this.callParent(arguments);

at the end of initComponent. Useful!

JonnyRaa
  • 7,559
  • 6
  • 45
  • 49
5

Don't override initComponent when creating an instance.

Ext.create('Ext.window.Window', {
    title: 'Login',
    width: 400,
    height: 500,
    items: [{
        xtype: 'textfield',
        fieldLabel: 'Net ID',
        allowBlank: false,
        labelWidth: 150,
        width: 150,
        emptyText: 'Net ID'
    }, {
        xtype: 'textfield',
        fieldLabel: 'Password',
        allowBlank: false,
        labelWidth: 150,
        width: 150,
        emptyText: 'Pass'
    }]
}).show(); 
Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66