Button click event Ext JS

六月ゝ 毕业季﹏ 提交于 2020-01-24 11:27:06

问题


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:


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.



来源:https://stackoverflow.com/questions/3119152/button-click-event-ext-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!