0
我是sencha touch框架中的新成員。我試圖首先創建用戶登錄。我想從表單中獲取用戶名和密碼併發送到api進行身份驗證。但我甚至無法獲得字段值。我的LoginForm視圖如下所示:檢索sencha touch 2 fieldsetss值
Ext.define('NCAPP.view.tablet.LoginForm', {
extend: 'Ext.form.Panel',
xtype:'loginForm',
id:'loginForm',
config: {
items: [
{
xtype: 'image',
src:'resources/img/netcenter_logo.png',
height: 100
},
{
xtype: 'fieldset',
title: 'NCAPP LOGIN:',
items: [
{
xtype: 'textfield',
id:'fldUsername',
name:'username',
placeHolder: 'Username'
},
{
xtype: 'textfield',
id:'fldPassword',
name:'passowrd',
placeHolder: 'Password'
}
]
},
{
xtype: 'button',
id: 'btnLogin',
text: 'Login'
}
]
}
});
和我的登錄控制器:
Ext.define('NCAPP.controller.tablet.LoginController', {
extend: 'Ext.app.Controller',
config: {
refs: {
loginForm:'#loginForm'
},
control: {
'#btnLogin':{
tap:'onLoginButtonTap'
}
}
},
onLoginButtonTap:function(){
var values=this.getLoginForm().getValues();
console.log(values.username); // want to see this output
Ext.ModelMgr.getModel('NCAPP.model.User').load(1,{
success: function(user){
//to do
},
failure: function(user){
console.log("failed");
}
});
},
init:function(application){
}
});
我沒有成功獲取用戶名字段的值。所顯示的錯誤是:
Uncaught TypeError: Object function() {
return this.constructor.apply(this, arguments);
} has no method 'LoginForm'
或有時這樣的錯誤:
Uncaught TypeError: Cannot call method 'getValues' of undefined
任何人可以幫助我,請....謝謝
感謝您的回覆,但即使在this.getLoginForm的末尾添加()後也有同樣的錯誤。我有兩個不同的配置文件:平板電腦和手機。我想知道這是否是問題? – Shree 2013-03-18 13:03:22
嗯,你可以嘗試改變你的參考'loginForm:'loginForm''。你有什麼應該工作,但只是爲了確保。 – jprofitt 2013-03-18 14:01:38
解決了這個問題。謝謝 – Shree 2013-03-18 14:59:04