我有一个窗口,它包含一些文本字段和一个按钮。这是按钮的定义;别名.widget:'mywin', ....
{
xtype: 'button',
height: 40,
width: 110,
text: 'send',
x: 58,
y: 12,
action: 'buttonclick'
},
在我的控制器中,我将检测此按钮单击并显示一个 console.log 语句。
这是代码;
初始化:函数(应用程序){ this.control({
'mywin button[action=buttonclick]': {
click: this.butClick
}
});
},
butClick: function(button,record) {
console.log('Button clicked');
这没有显示出来,我该如何解决?
更新
Ext.define('MyApp.view.MyWindowClass', {
extend: 'Ext.window.Window',
alias: 'widget.mywin',
height: 340,
id: 'mywinid',
width: 728,
layout: {
type: 'absolute'
},
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'textareafield',
height: 140,
width: 340,
fieldLabel: 'Name',
x: 370,
y: 80
},
{
xtype: 'button',
height: 40,
width: 210,
text: 'Save',
x: 480,
y: 240,
action: 'submitfeedback'
},
{
xtype: 'datefield',
id: 'dd',
readOnly: true,
fieldLabel: 'Today',
x: 10
}
],
listeners: {
show: {
fn: me.onWindowShow,
scope: me
}
}
});
me.callParent(arguments);
}
});
控制器
Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
models: [
'MyController'
],
stores: [
'MyController'
],
views: [
'MyWindowClass',
],
init: function(application) {
this.control({
'mywin button[action=submitfeedback]': {
click: this.butClick
}
});
},
butClick: function(button,record) {
console.log('button clicked');
});
}
});