FrenkyB
FrenkyB

Reputation: 7217

ExtJS Cannot read property 'addClass' of null

I am trying to dynamically add form to another form, but the error is thrown:

Uncaught TypeError: Cannot read property 'addClass' of null

I really don't understand this, because I can add f.e. new Ext.Button({text: 'testing'}). But form can not be added? Why?

Fiddle is here

var frmTemplate = new Ext.form.FormPanel({
        border: false,
        items: [{
                layout: 'hbox',
                border: false,
                items: [

                    {
                        xtype: 'textfield',
                        emptyText: 'testing 123...',
                        hideLabel: true
                    }, {
                        xtype: 'button',
                        text: 'testiranje',
                        style: {
                            marginLeft: '10px'
                        }
                    }

                ]
            }

        ]
    });

    var form1 = new Ext.form.FormPanel({
        layout: 'fit'
    });

    form1.add(frmTemplate);

    form1.render(document.body);
    form1.doLayout();

Upvotes: 0

Views: 769

Answers (1)

Arthur Rubens
Arthur Rubens

Reputation: 4706

Just change the parent to Ext.Panel or child to Ext.Panel:

Ext.onReady(function () {

    var frmTemplate = new Ext.form.FormPanel({
        //var frmTemplate = new Ext.Panel({
        border: false,
        items: [{
            layout: 'hbox',
            border: false,
            items: [{
                xtype: 'textfield',
                emptyText: 'testing 123...',
                hideLabel: true
            }, {
                xtype: 'button',
                text: 'testiranje',
                style: {
                    marginLeft: '10px'
                }
            }]
        }]
    });

    //var form1 = new Ext.form.FormPanel({
    var form1 = new Ext.Panel({
        layout: 'fit'
    });

    form1.add(frmTemplate);

    form1.render(document.body);
    form1.doLayout();

});

Upvotes: 1

Related Questions