Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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);
— asked November 10th 2010 by Eamonn Hynes
  • appcelerator
  • windows
0 Comments

1 Answer

  • Accepted Answer

    Eamonn

    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 here
    

    Remember javascript is case sensitive, so watch for misspelled vars etc!

    — answered November 10th 2010 by Paul Dowsett
    permalink
    1 Comment
    • Hey,

      Many thanks for the reply. I'll give that later on today when I have time and I'll get back to you.

      — commented November 11th 2010 by Eamonn Hynes
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.