如何使用sencha ouch获取表单值并将该值插入到数据库中 [英] how to get the form values and insert that values in the db using sencha touch
本文介绍了如何使用sencha ouch获取表单值并将该值插入到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望将登录表单详细信息存储在数据库中。为此,我编写了以下代码。
在我的视图代码中
Ext.define('SampleForm.view.LoginForm', {
extend: 'Ext.form.Panel',
//id:'loginform',
requires:[
'Ext.field.Email',
'Ext.field.Password'
],
config: {
fullscreen: true,
layout:{
type:'vbox'
},
items: [
{
xtype: 'fieldset',
title: 'Login',
id: 'loginform',
items: [
{
xtype:'textfield',
label:'Name',
name:'name'
},
{
xtype: 'emailfield',
name: 'email',
label: 'Email'
},
{
xtype: 'passwordfield',
name: 'password',
label: 'Password'
}
]
},
{
xtype: 'button',
width: '30%',
text: 'Login',
ui: 'confirm',
action:'btnSubmitLogin'
}
]
}
});
在控制器中
Ext.define("SampleForm.controller.LoginForm", {
extend: "Ext.app.Controller",
config: {
view: 'SampleForm.view.LoginForm',
refs: [
{
loginForm: '#loginform',
Selector: '#loginform'
}
],
control: {
'button[action=btnSubmitLogin]': {
tap: "onSubmitLogin"
}
}
},
onSubmitLogin: function () {
alert('Form Submitted successfully');
console.log("test");
var values = this.getloginform();
/* Ext.Ajax.request({
url: 'http://www.servername.com/login.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);
}
});*/
form.submit({
url:"http://localhost/sencha2011/form/login.php"
});
},
launch: function () {
this.callParent();
console.log("LoginForm launch");
},
init: function () {
this.callParent();
console.log("LoginForm init");
}
});
当我单击提交按钮时,出现警告消息,但值没有存储在数据库中。在控制台IM收到此错误时,未捕获TypeError:Object[Object Object]没有方法‘getloginfo’。
有人能帮助我如何在数据库中插入值吗?
推荐答案
Java区分大小写发件人Sencha Touch docs:
这些getter函数是根据您定义的引用和 始终遵循相同的格式-‘GET’后跟大写的REF 姓名。
要使用ref的getter方法loginForm
并获取表单值,请使用:
var values = this.getLoginForm().getValues();
这篇关于如何使用sencha ouch获取表单值并将该值插入到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文