下面是我为云用户login...the使用的代码,很小的问题是:每当我登录和注销时,插入到textfields中的数据不会消失,我不希望它们被保存,我希望用户在注销后再次插入textfields。
//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);
}
});
});发布于 2013-10-10 18:50:24
我想你想要清除文本框。成功登录后,只需清空textFields即可。为此,只需按以下方式修改代码
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);
}
});
});这将起到以下作用:)
https://stackoverflow.com/questions/19300984
复制相似问题