3

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?

1 Answer 1

7

You either need

a) The handler option (a click shortcut)

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

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

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

A) is preferred.

Sign up to request clarification or add additional context in comments.

2 Comments

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!
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.