Open a window
How do I open a window from within another window?
I have the following structure:
app.js
---login.js
---signUp.js
Windows login (login.js) and signUp (signUp.js) are defined in app.js. I want to be able to show signUp.js from within login.js
Here is my code:
app.js:
var win_login=Titanium.UI.createWindow({
    url:'wins/login.js',
    title:'Login',
        backgroundColor:'#CCC',
        navBarHidden:true
});
var win_signUp=Titanium.UI.createWindow({
        url:'wins/signUp.js',
    title:'Sign-up',
        backgroundColor:'#CCC',
        navBarHidden:true
});
win_login.open();
Here is login.js:
var win = Titanium.UI.currentWindow;
var login=Titanium.UI.createButton({
   title:'Login',
     width:250,
     top:330
});
login.addEventListener('click', function(e){
   /////
   //how do I open the signUp window here???
   /////
});
win.add(login);
Here is signUp.js:
var win = Titanium.UI.currentWindow;
var signUp=Titanium.UI.createButton({
   title:'Sign-up',
     width:250,
     top:330
});
win.add(SignUp);
1 Answer
- 
				
					Accepted AnswerEamonn It's fine for you to ask questions in the Q&A, but when someone has helped, remember to do your part by marking the best answer to close the post. Anyway, I think you nearly there, with your code. Try this: app.js: var win_login=Titanium.UI.createWindow({ url:'wins/login.js', title:'Login', backgroundColor:'#CCC', navBarHidden:true }); win_login.open();login.js var win = Titanium.UI.currentWindow; var login=Titanium.UI.createButton({ title:'Login', width:250, top:330 }); win.add(login); var signUp=Titanium.UI.createButton({ title:'Sign-up', width:250, top:330 }); win.add(signUp); var win_signUp=Titanium.UI.createWindow({ url:'wins/signUp.js', title:'Sign-up', backgroundColor:'#CCC', navBarHidden:true }); login.addEventListener('click', function(e){ win_signUp.open(); });signUp.js: var win = Titanium.UI.currentWindow; // add your signup screen views and logic hereRemember javascript is case sensitive, so watch for misspelled vars etc!