對sencha touch有所觸動。我已經在網上查了很多教程。我有一個問題試圖獲得文本字段的值。我點擊登錄按鈕時發生的錯誤是Uncaught TypeError: Cannot call method 'getValue' of undefined
。這是否意味着我的Ext.getCmp
未定義呢?我有這個面板包裹在常規Ext.setup....onReady:.....
在Sencha Touch中未定義的getValue
var login = new Ext.Panel({
height:'auto',
scroll:'vertical',
layout:{
type:'vbox',
align:'center'
},
items:[
{
cls:'launchscreen',
html:logo,
padding:10
},
new Ext.form.FormPanel({
width:300,
cls:'loginform',
items:[
{
xtype: 'fieldset',
title: 'Login',
items: [
{
xtype: 'textfield',
name : 'username',
label: 'Username',
labelWidth: 85
},
{
xtype: 'passwordfield',
name : 'password',
label: 'Password',
labelWidth: 85
}
]
},
{
xtype: 'button',
text: 'Submit',
ui: 'confirm',
handler:function()
{
alert(Ext.getCmp('username').getValue());
}
}
]
})
]
});
編輯:我能得到的值,如果我設置的文本字段中id
屬性。我已經看到一些示例,其中id
未設置,它們基於name
屬性獲取值。所以我想現在我的問題是我應該得到基於id
或name
的價值?
是的,我想傳遞ID是更好的結局。謝謝(你的)信息。我無法在他們的文檔中找到getCmp方法 – Ronnie 2012-01-30 21:48:38