Model view controller Sencha Touch MVC::正在尝试访问Ext.extend(Ext.form.FormPanel,…)的getValues()
我正试图在我的sencha touch应用程序中实现我的表单价值,该应用程序是由补缀的教程构建而成的。我希望它是一个MVC模式的应用程序,所以我使用Model view controller Sencha Touch MVC::正在尝试访问Ext.extend(Ext.form.FormPanel,…)的getValues(),model-view-controller,sencha-touch,extjs,formpanel,Model View Controller,Sencha Touch,Extjs,Formpanel,我正试图在我的sencha touch应用程序中实现我的表单价值,该应用程序是由补缀的教程构建而成的。我希望它是一个MVC模式的应用程序,所以我使用 app.views.Login = Ext.extend(Ext.form.FormPanel, formBase = {...}) 在里面用 app.views.Login.superclass.initComponent.apply(this, arguments); 还有一个类似sencha touch phonegap MVC教程()
app.views.Login = Ext.extend(Ext.form.FormPanel, formBase = {...})
在里面用
app.views.Login.superclass.initComponent.apply(this, arguments);
还有一个类似sencha touch phonegap MVC教程()中的视口,我在其中应用了登录页面,如
Ext.apply(app.views, {loginPage: new app.views.Login()});
在我的应用程序中,当我单击表单的“发送”按钮时,我尝试捕获表单的字段
handler: function() {
console.log('username ', app.views.Login.getValues().username);
Ext.Ajax.request({
url: app.views.Login.url,
method: 'POST',
params: {username: form.getValues().username, password : form.getValues().password},
failure : function(response){
console.log('Login Error! ' + response.responseText);
},
success: function(response, opts) {
console.log('Login success! response: ' + response.responseText);
}
});
}
但我总是会犯一个错误
未捕获的TypeError:无法调用方法
未定义的“getValues”
当我使用
console.log('username ', this.getValues().username);
那么,我如何才能获得表单值呢
thnx!!!看,我没有看到一个方法getForm()
,但是getValues()
应该可以通过按钮处理程序函数这样访问:
app.views.loginPage.getValues();
查看,我没有看到方法getForm()
,但是可以通过按钮处理程序
函数像这样访问getValues()
:
app.views.loginPage.getValues();
@Tommi hey thanx感谢你在这方面的批评。我不得不为我糟糕的描述道歉。我编辑了我的问题,希望能更好地描述我的问题…请参阅我上面的评论-处理程序
看起来像什么?但是我在视口中定义的表单是“Ext.apply(app.views,{loginPage:new app.views.Login()”;“那么我应该在哪里声明一个附加的”var login=new app.views.login({…});“?好的。再试一次。再次更新我的答案。samesame->Uncaught TypeError:Object[Object Object]没有方法“getValues”@Tommi hey thanx来回答你的问题。我不得不为我糟糕的描述道歉。我编辑了我的问题,希望能更好地描述我的问题…请参阅我上面的评论-处理程序
看起来像什么?但是我在视口中定义的表单是“Ext.apply(app.views,{loginPage:new app.views.Login()”;“那么我应该在哪里声明一个附加的”var login=new app.views.login({…});“?好的。再试一次。再次更新了我的答案。samesame->Uncaught TypeError:Object[Object Object]没有“getValues”方法。我认为您还应该在问题中包括发送按钮的代码(特别是它的处理程序
)。编辑:将“this.getValues().username”更改为“app.views.Login.getValues()”.username'-但仍然不起作用。错误:“uncaughttypeerror:Object函数(){superclass.apply(这是参数);}没有方法'getValues'”hm,因此如果没有解决方案,我想我必须将登录页面从视口中移出……我想您还应该包括发送按钮的代码(特别是它的处理程序
)在问题中。编辑:将“this.getValues().username”更改为“app.views.Login.getValues().username”-但仍然不起作用。错误:“Uncaught TypeError:Object function(){superclass.apply(this,arguments);}没有方法“getValues””hm,因此如果没有解决方案,我想我必须将登录页从视口中删除。。。