mainWin.pageLoad=false;
mainWin.addEventListener('load', function(e) {
if(mainWin.pageLoad) {
mainWin.open();
} else {
mainWin.close();
var LoginWindow = Titanium.UI.createWindow({
title : 'Login',
url:'Login.js'
});
LoginWindow.open();
}
});
This is my app.js file. If the pageLoad variable holds the boolean value true, then i need to navigate to mainWin {Which is the current Wind开发者_如何转开发ow}
else i need to go to Login Page.
var LoginWindow = Titanium.UI.createWindow ({
backgroundColor:'#1E563F',
url:'Login.js',
});
mainWin.addEventListener('open', checkPage);
mainWin.pageLoad = false;
function checkPage() {
if(mainWin.pageLoad) {
mainWin.open();
} else {
mainWin.close();
LoginWindow.open();
}
}
mainWin.open();
This should work....
Did you try to put your code like this ?
mainWin.pageLoad = false;
mainWin.addEventListener('load', function(e) {
if(mainWin.pageLoad) {
mainWin.open();
} else {
mainWin.close();
var LoginWindow = Titanium.UI.createWindow({
title : 'Login',
url:'Login.js'
});
LoginWindow.open();
}
});
The reason is probably that the the variable is updated to true before the event is dispatched. Did you try to print to console the mainWin.pageLoad value? Where do you update the variable to true?
try using the focus
event instead of the load event.
精彩评论