使用sencha触摸调用函数时出错 [英] getting error when calling the function using sencha touch
本文介绍了使用sencha触摸调用函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复项:
how to get the form values and insert that values in the db using sencha touch
我是Sencha Touch的新手。我想创建一个表单并在数据库中提交该表单详细信息。为此,我编写了以下代码。
Ext.define("Form.view.Main",{
extend: "Ext.form.Panel",
requires:['Ext.Button',
'Ext.Spacer',
'Ext.field.Password'
],
config: {
fullscreen: true,
id:'form',
items: [
{
xtype:'fieldset',
items:[
{
xtype: 'textfield',
name : 'name',
label: 'Name'
},
{
xtype: 'emailfield',
name : 'email',
label: 'Email',
placeHolder: 'Email address',
useClearIcon: true
},
{
xtype: 'passwordfield',
name : 'password',
label: 'Password',
allowBlank:'false'
}
]
},
{
centered:'true',
xtype:'button',
id:'submitBtn',
text:'Submit',
ui:'confirm',
width:100,
listeners: {
tap : function(thisTxt,eventObj){
var form = Ext.getCmp('form');
var values = thisTxt.getValues();
alert(values.name);
Ext.Ajax.request({
url:'http://localhost/sencha2011/form/insert.php',
params:values,
success : function(response){
var text = response.responseText;
Ext.Msg.alert('Success', text);
},
failure : function(response){
Ext.Msg.alert('Error','Error while submitting the form');
console.log(response.responseText);
}
});
}
}
}
]
}
});
当我尝试执行此应用程序时,已成功执行(调试)。当我在浏览器中打开该应用程序时,在控制台窗口中显示错误信息为"未捕获类型错误:无法调用未定义的方法‘getValues’",并且只显示表单。当我单击提交按钮时,什么也没有发生。有人可以帮助解决这个问题吗?
先谢谢你……
推荐答案
而不是
var values = thisTxt.getValues();
尝试
var values = form.getValues();
或
var values = this.parent.getValues();
因为thisTxt
是button不是表单,应该在表单面板上调用getValues()。
这篇关于使用sencha触摸调用函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文