Titanium登录/注册 [英] Titanium Login/Registration
本文介绍了Titanium登录/注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我用于云用户登录的代码...轻微的问题是;每当我登录并注销时,插入文本字段的数据不会消失...我不希望保存它们,我希望用户注销后重新插入文本字段.
Below is the code i use for my cloud user login...the slight problem is; whenever i login and logout, data inserted into the textfields does not disappear...i don't want them to be saved, i want users to insert textfields all over again after logout.
//create textfields for sign_in page/interface
var userNameField = Titanium.UI.createTextField({
color: 'black',
hintText: 'username',
height: 35,
top: 120,
left: 10,
width: 250,
borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(userNameField);
var passwordField = Titanium.UI.createTextField({
color: 'black',
hintText: 'password',
height: 35,
top: 160,
left: 10,
width: 250,
passwordMask: true,
borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(passwordField);
var button = Titanium.UI.createButton({
title: 'log in',
top: 190,
left: 10,
width: 100,
height:50,
Color:'#336699'
});
win.add(button);
//then create event listener and login user to ACS cloud server
button.addEventListener('click', function(){
Cloud.Users.login({
login: userNameField.value,
password: passwordField.value,
}, function (e) {
if (e.success) {
var user = e.users[0];
alert('success');
} else {
alert('Unable to log you in:' + e.message);
}
});
});
推荐答案
我认为您想清除文本字段.成功登录后,您只需要清空textFields.为此,您只需要按如下所示修改代码
I think you want to clear the textfields. You just need to empty the textFields upon successful login. For this you just need to modify your code as follows
button.addEventListener('click', function(){
Cloud.Users.login({
login: userNameField.value,
password: passwordField.value
}, function (e) {
if (e.success) {
var user = e.users[0];
//Clears the TiUITextField's values
userNameField.value = "";
passwordField.value = "";
alert('success');
} else {
alert('Unable to log you in:' + e.message);
}
});
});
这可以解决问题:)
这篇关于Titanium登录/注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文