Jacobian
Jacobian

Reputation: 10882

How to implement renderTo on the fly

I have this simple code, in which I iterate through a form fields:

frm.getFields().each(function(field) {
    ....
});

What I want to achieve is to render some fields to some html elements (in case some condition is met - which in fact does not matter). So, I want to implement something like:

frm.getFields().each(function(field) {
    if(ok){
        field.renderTo(document.getElementById(some_id));
    }
});

I know how it statically works, just like:

Ext.create(..., function(){
    renderTo:...
});

But I want to do this dynamically, like I said above.

Upvotes: 0

Views: 40

Answers (1)

Guilherme Lopes
Guilherme Lopes

Reputation: 4760

renderTo is the config option, if you need to render an ExtJS component use the render method.

Something like:

<div id="renderHere"></div>

var myField = Ext.create({
        xtype : 'textfield',
        fieldLabel : 'Test'
    });

myField.render('renderHere');

Upvotes: 1

Related Questions