Reputation: 632
I have a function :
var my_form = function() {
return {
layout:'form',
items: [
{
xtype:'textfield',
fieldLabel: "Name",
maxLength: 255
}
]
};
}
I want to render it dynamically. This doesn't work :
var t = Ext.DomHelper.createTemplate(my_form()).compile();
Ext.DomHelper.insertBefore('my_div', t);
How to do this ?
Thanks :)
Upvotes: 0
Views: 1410
Reputation: 10263
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());
});
Upvotes: 1