【发布时间】:2013-08-18 14:36:54
【问题描述】:
在我的应用程序中,我在工具栏中有一个按钮。如果我单击此按钮打开一个窗口,则会执行以下代码:
[...]
onClick: function() {
this.windowControl = this.getController('attributesearch.Window');
this.windowControl.init();
this.windowControl.showWindow();
}
[...]
此窗口包含一些输入字段和一个带有商店的组合框:
Ext.define('EM.store.AttributeQuery', {
requires: ['EM.model.AttributeQuery'],
model: 'EM.model.AttributeQuery',
proxy: {
type: 'ajax',
url: './app/configuration/AttributeQueries.json',
reader: {
type: 'json',
root: 'queries'
}
},
autoLoad: true
});
在我的窗口控制器的 init 方法中,我想添加一个 onLoad-listener
我尝试将此侦听器添加到商店:
init: function() {
this.getAttributeQueryStore().on('load', this.onStoreLoad, this);
this.control({
'attributeSearchWindow': {
afterrender: this.onWindowRendered
}
});
},
init 方法this.getAttributeQueryStore().on('load', this.onStoreLoad, this); 的第一行产生以下错误:
Uncaught TypeError: Object [object Object] has no method 'on' app/controller/attributesearch/Window.js:9.
似乎商店没有完全(或正确)实例化。我错过了什么?
编辑:
this.getAttributeQueryStore() 的控制台输出如下:
constructor {self: function, superclass: Object, config: emptyFn, initConfigList: Array[0], initConfigMap: Object…}
__proto__: TemplateClass
$className: "EM.store.AttributeQuery"
autoLoad: true
config: emptyFn
configMap: TemplateClass
initConfigList: Array[0]
initConfigMap: Object
model: "EM.model.AttributeQuery"
proxy: Object
requires: Array[1]
self: function constructor() {
superclass: Object
__proto__: Object
}
【问题讨论】:
-
在控制台上检查
store,可能store无法访问 -
将 console.log 的响应编辑到我的问题中。商店是某种东西,但似乎没有像我期望的那样被实例化(不管它是什么)。我找不到方法“on”或“addListener”或 ExtJS 文档显示给我的任何其他方法。
-
在渲染事件后尝试在窗口上绑定
store load事件 -
如果我尝试在 afterrender 事件中添加监听器,我会得到同样的错误。
标签: extjs controller store