views:

584

answers:

1

I have the simple form:

   myForm = new Ext.form.FormPanel({
      width:'100%',
      frame:false,
      items: [
         new Ext.form.TextArea({
            id:'notes',
  name: 'notes',
  hideLabel: true,
            width:350,
            height:200
         })
      ],
      buttons: [
         {
    text:"Save",
    click: function (b,e) {
     alert('x');
    }
  }
      ]
   });

However I am having trouble getting the click event of the button to work. Do buttons created the following way have the same functionality of doing Ext.Button?

A: 

You either need

a) The handler option (a click shortcut)

new Ext.Button({
    handler: function(){ 
        // ....
    }
});

b) Evenent listeners need to be registered in in a listeners block, so

new Ext.Button({
    listeners: {
        click: function(){
            // ...
        }
    }
});

A) is preferred.

Evan Trimboli
Yeah I ended up having to use a Ext.Button, I just thought it was a bit better practice to make use of the buttons section!
roobotta
You can add the handler config to a button config in your buttons array -- you do not have to create an Ext.Button() object to do that.
bmoeskau