建筑LOGIN不是一个函数
问题描述:
我尝试创建一个使用PHP与ExtJS的登录,但我坚持了这个问题...建筑LOGIN不是一个函数
TypeError: this.getView is not a function
this.getView().destroy();
这里是我的代码....
我不知道为什么它可能是错误,我只是尝试按照煎茶文档
buttons: [{
text: 'Login',
formBind: true,
listeners: {
click: function() {
var form = Ext.getCmp('login').getForm();
if(form.isValid()) {
form.submit({
url : 'data/login.php',
method : 'POST',
success:function(){
this.getView().destroy();
Ext.widget('app-main');
},
failure: function() {
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors);
}
});
}
}
}
}]
答
您是否尝试过console.log(this)
教程?我猜不是...
this
总是依赖于上下文。这里的上下文不是视图,但是,如果我没有弄错,Ext.Ajax.request,其中的success
函数试图破坏视图。
这就是为什么我在我的代码使用该避免无论它是不是完全明显甚至是外行的读者,我这方面的
编辑:由于代码看起来不好的评论,我在这里添加它。 答案按原来的分机来源是
click: function() {
var me = this;
var form = Ext.getCmp('login').getForm();
if(form.isValid()) {
form.submit({
url : 'data/login.php',
method : 'POST',
success:function(){
me.getView().destroy();
Ext.widget('app-main');
},
failure: function() {
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors);
}
});
}
}
而我个人会用
click: function(btn) {
var form = Ext.getCmp('login').getForm();
if(form.isValid()) {
form.submit({
url : 'data/login.php',
method : 'POST',
success:function(){
btn.up('window').hide();
Ext.widget('app-main');
},
failure: function() {
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors);
}
});
}
}
嗨,先生你有什么想法要解决或如何实现我想要做即时通讯相当卡住了创建一个登录和IM只是在extjs – itsmecidz 2014-09-22 09:38:10
begineer我在原来的帖子中添加了一些代码。 – Alexander 2014-09-22 09:44:45
谢谢先生!我尝试了第一个,但我没有工作,然后我尝试第二个,它的工作原理!感谢你的时间 – itsmecidz 2014-09-22 10:01:52