Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

change url on win

$
0
0

Hi. I am making an app with a login page.

When a user has logged in i dont want them to do it again so here is what i have tried. (With no luck)

What am i doing wrong?

app.js

var user = Ti.App.Properties.getString('user');
var win1 = Titanium.UI.createWindow({  
    url: 'first.js',
    title:'Title',
    barColor: '#050505',
    exitOnClose     : false,
    backgroundColor:'#050505',
    navBarHidden: false
});
if (user === ''){
    win1.applyProperties({url       :  'login.js'});
}
My login win
var empname = Titanium.UI.createTextField({
    hintText : 'Name',
    color : '#FFF',
    width : '200dp',
    height : '50dp',
    top :'180dp',
    borderColor : 'transparent',
    paddingLeft:'15sp',
    backgroundImage : '/images/field.png'
});
win.add(empname);
 
 
var btnSubmit = Ti.UI.createButton({
    backgroundImage : '/images/field.png',
    height: '55dp',
    width: '200dp',
    top : '290dp'
 
});
var buttonLabel = Titanium.UI.createLabel({
    color:'#fff',
    font:{fontSize:'17sp',fontWeight:'bold',fontFamily:'Arial'},
    text:'Log in',
    textAlign:'center',
    touchEnabled:false,
    top:btnSubmit.top,
    height:btnSubmit.height,
    width:btnSubmit.width
});
win.add(btnSubmit);
win.add(buttonLabel);
 
btnSubmit.addEventListener('click', function(e) {
 
    if (empname.value === '') {
        alert('You forgot Name...');
    } else {
        if (empname.value ) {
 
            open();
            Ti.App.myUsername= empname.value;
          Ti.App.Properties.setString('user', empname.value);
        } 
    }
});
 
win.open();
as you can see i have tried with Ti.App.myUsername also and that works so i can use it through out the app in later views/win but not in my app.js

Any ideas?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>