Ext.define('BgWeb.controller.HomeController', { extend: 'Ext.app.Controller', views: ['Viewport', 'Main_Left', 'Main_Center'], refs: [ { ref: 'Main_propertygrid', selector: 'propertygrid' }, { ref: 'Main_Center', selector: 'Main_Center' }, ], init: function () { this.control({ 'propertygrid': { beforeedit: function (e) { return false; } } },{ 'Main_Center button[id=Cancelbtn]': { click: function (button) { Ext.Msg.alert('Status', 'Changes saved successfully.'); } } }); } });
Ext.define('BgWeb.view.Main_Center', { extend: 'Ext.panel.Panel', border: false, alias: 'widget.Main_Center', items: [{ region: 'center', layout: 'fit', xtype: 'tabpanel', alias: 'widget.Main_tabpanel', activeTab: 0, items: [{ title: '主页', layout: 'anchor', xtype: 'form', defaultType: 'textfield', defaults: { anchor: '80%', margin: '10px' }, items: [ { fieldLabel: 'Foo' }, { fieldLabel: 'Bar', xtype: 'filefield' }, { fieldLabel: 'Num', xtype: 'numberfield' } ], buttons: [ { xtype: 'button', text: 'Cancel', id: 'Cancelbtn', action: 'Cancelbtn' }, { text: 'Send' } ] }] }] });
Cancelbtn按钮事件点击没有反应,求解哪里错了
按钮点击事件不是你这样写的啊
{
xtype: 'button',
text: 'Cancel',
id: 'Cancelbtn',
handler:function(){
//你要执行的方法
}
},
上面初始化时定义按钮的方法去掉