我有一个窗口,它包含一些文本框和一个按钮。这是按钮的定义; alias.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');
这是没有得到显示,我怎么能解决这个问题
UPDATE
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);
}
});
?
CONTROLLER
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');
});
}
});
该代码看起来不错,但你没有其他的JS错误?当我尝试创建该窗口时出现错误。 – nscrob 2012-07-24 15:08:56
你的控制器加载正确吗? – 2012-07-24 19:57:18