ExtJS 4 callParent 不工作
我试图找出为什么 callParent 不起作用。
这是一些代码:
Ext.define('AM.ArView', {
extend:'Ext.window.Window',
initComponent: function() {
var foo = this;
console.log(foo);
Ext.Ajax.request({
url: 'http://my/awesome/path',
success: function(response, opts) {
console.log(foo);
foo.callParent();
},
failure: function(response, opts) {
console.log('error');
}
});
}
});
错误: 未捕获的类型错误:无法读取未定义的属性“超类”
我需要通过ajax加载Windows项目
I'm trying to figure out why callParent isn't working.
Here's some code:
Ext.define('AM.ArView', {
extend:'Ext.window.Window',
initComponent: function() {
var foo = this;
console.log(foo);
Ext.Ajax.request({
url: 'http://my/awesome/path',
success: function(response, opts) {
console.log(foo);
foo.callParent();
},
failure: function(response, opts) {
console.log('error');
}
});
}
});
Error:
Uncaught TypeError: Cannot read property 'superclass' of undefined
I need to load the windows items via ajax
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嘿朱利安!
我需要执行类似的操作,最后我将 ajax 请求包装在一个函数中,我将回调函数传递给它以在请求完成时执行,然后从回调中启动窗口。
就代码而言,它会是这样的:
然后你调用 int let,说单击按钮:
HTH!
Hei Julian!
I needed to do a similar operation, and i ended up wrappign the ajax request in a function which i pass a callback function into it to execute when the request is done, and from the call back i launch the windows.
In terms of code, it would be something like:
then you call int lets, say ona button click:
HTH!
我需要将回调与
callParent
传递到Ext.Msg.*
对话框中。老实说,我不明白如何使用答案中的代码来处理我的案例......并用 hack 解决了它。在 4.0.7 中工作:
I needed to pass callback with
callParent
intoExt.Msg.*
dialog. Honestly I didn't understand how to use code from answer for my case... and solved it with hack.Working in 4.0.7:
有点晚了,但希望它对其他人有帮助...
而不是调用
this.callParent();
您需要调用
this.self.superclass.foo.call(this);
code>foo 是您要调用的超类方法。
要包装它并使其看起来更有意义:
请参阅:
ExtJS 4 - 对 callParent 的异步回调抛出异常
A bit late, but hope it helps others...
Instead of calling
this.callParent();
You need to call
this.self.superclass.foo.call(this);
foo being the superclass method you want to call.
To wrap it up and make it look more meanful:
See this:
ExtJS 4 - async callback to callParent throws exception