0

我定义了以下视图:

    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 架构,所以请假设我的应用程序的其他部分是正确的。

4

1 回答 1

1

您必须为Object配置listeners参数提供一个,如Observable 文档中所述。你用了一个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);
  }
});
于 2012-08-20T13:15:02.457 回答