开发者

ExtJs - Render object 'layout form' dynamically in DOM

I have a function :

var my_form = function() {
    return {
        layout:'form',
        items: [
            {
                xtype:'textfield',
                fieldLabel: "Name",
                maxLength: 255
            }
        ]
    };
}

I want to render it dynamically. 开发者_Python百科This doesn't work :

var t = Ext.DomHelper.createTemplate(my_form()).compile();
Ext.DomHelper.insertBefore('my_div', t);

How to do this ?

Thanks :)


I found out it can work this way: first create a div via DomHelper, then create the FormPanel using the "renderTo" config option.

Ext.onReady(function(){

    var formdiv = Ext.DomHelper.insertBefore('my_div', {tag: 'div', id: 'form_div' } );

    var my_form = function() {
        return {
            layout:'form',
            renderTo:'form_div',
            items: [
                {
                    xtype:'textfield',
                    fieldLabel: "Name",
                    maxLength: 255
                }
            ]
        };
    }

    var t = new Ext.FormPanel(my_form());

});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜