user1672155
user1672155

Reputation:

ExtJS setting a textareafield setValue()

Im learning Extjs and have a problem , when i try to append new text to an item i get an error tf.setValue is not a function same goes for getValue. When i try setVisible it works like it should be.

Ext.Loader.setConfig({enabled:true});

Ext.application({
    name: 'app',
    controllers:[
  ],
    appFolder: 'app',
    launch: function() {
        var panel = new Ext.form.FormPanel({
          renderTo:Ext.getBody(),
          title:'Panel',
          width:400,
          bodyPadding: 10,
          autoHeight:true,
          items:[{
            xtype:'textareafield',
            name: 'textInput',
            id:'textId',
            value:'why not'
          },{
            xtype:'button',
            text:'Helllo',
            handler:function(){
              console.log('button click')
              var tf = Ext.get('textId');
                    tf.setValue('This should change!')
            }
          }],
        });
    }
});

Thanks

Upvotes: 0

Views: 6011

Answers (1)

dougajmcdonald
dougajmcdonald

Reputation: 20037

That's because Ext.get() will return an Ext.Element.

What you want to use is Ext.getCmp('textId') which will return the component.

The Element is basically the Ext wrapper round the Dom element, so it has methods like setVisible, but you want to get the text area component, which has all the methods you're after.

Upvotes: 2

Related Questions