首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >钛登录/注册

钛登录/注册
EN

Stack Overflow用户
提问于 2013-10-10 16:11:37
回答 1查看 645关注 0票数 0

下面是我为云用户login...the使用的代码,很小的问题是:每当我登录和注销时,插入到textfields中的数据不会消失,我不希望它们被保存,我希望用户在注销后再次插入textfields。

代码语言:javascript
复制
//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);
    }
    });
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-10 18:50:24

我想你想要清除文本框。成功登录后,只需清空textFields即可。为此,只需按以下方式修改代码

代码语言:javascript
复制
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);
        }
    });
});

这将起到以下作用:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19300984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档