我已经定义了以下视图:
Ext.define("app.view.stock.SearchValueField", {
extend: "Ext.form.field.Text",
alias: "widget.searchvaluefield",
name: "search_value_field",
enableKeyEvents: true,
allowBlank: false,
listeners: [
{
keyup: {
fn: function(){console.log('logged');}
}
}
],
initComponent: function() {
this.callParent(arguments);
}
});
但是在keyup上,侦听器没有被触发。我非常精通mvc架构,所以请假设我的应用程序的其他部分是正确的。
答案 0 :(得分:1)
您必须为Object
配置参数提供listeners
,如Observable documentation中所述。
您使用了Array
。它使用以下代码:
Ext.define("app.view.stock.SearchValueField", {
extend: "Ext.form.field.Text",
alias: "widget.searchvaluefield",
name: "search_value_field",
enableKeyEvents: true,
allowBlank: false,
listeners: {
keyup: function() {
console.log('logged');
},
},
// actually the 'empty' override of initComponent isn't necessary
initComponent: function() {
this.callParent(arguments);
}
});