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

How to close modal window that's inside a modal window

$
0
0

I'm developing for iOS (7+) and using Ti SDK 3.2.0.

My application is a tabbed application that shows a modal login window before opening the tabgroup. From the login window, the user can either log in and gets taken to the app/tabgroup or register.

Clicking the register button opens up a new modal window via a fire event. Because of the app event listener/fire event the modal window is created from my AppTabGroup.js with a createnavigationwindow because of the ios7-migration. This is needed so users that open the register modal window can go back to the login screen using the leftnavbutton (in case they realize they're already registered ;-)).

My problem is as follows: after filling out the register fields and clicking the sign up button the user should (after validation) be taken to the app / AppTabGroup and both the register modal window and login modal window should be closed. I just can't figure out how to close the signup window. Closing the login window after succesfull login is no problem.

I've also tried separating different cases: if SHOW_SIGNUP is called with 'close' as a parameter it should close the window, but no success there..

Any tips? Thank you in advance!

// app.js code for showing the login modal window before opening the app (tabgroup)
 
if(loggedIn!=1 && token==='')
        {
 
        // Ti.API.info('load the login window..');
 
        var loginNow = require("ui/LoginWindow");
        var wind = new loginNow({});
 
        wind.open(
                { animated : false, 
                  modal : true, 
                }
                );
 
        }
 
        App = new AppTabGroup(ProductData);
        App.open();
// LoginWindow.js code for firing event to open the signup window
 
 
    var registerBtn = Titanium.UI.createButton({
        title:'Register',
        top:10,
        width:90,
        height:35,
        borderRadius:1,
        font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
    });
 
    Window.add(registerBtn);
 
    var launchSignup = function(e){
 
    Ti.App.fireEvent(
                "APP:SHOW_SIGNUP",
                {  }
            );
        };
 
        registerBtn.addEventListener(
            "click",
            launchSignup
        );
// app event listener in AppTabGroup.js for showing the signup window
 
 
    Ti.App.addEventListener(
        "APP:SHOW_SIGNUP",
 
        function(e){
 
            var newCard = require("ui/SignupWindow");
            var wind = new newCard();
            var navWin = Ti.UI.iOS.createNavigationWindow({
            modal: true,
            window: wind
            });
 
            var btnCloseWindow = Ti.UI.createButton({
            title : '< Login',
            navTintColor    : "#2a7407",
            color: '#fff',
            font         : {
                    fontSize   : 18,
                },
            borderWidth: 0,
            });
 
            wind.leftNavButton = btnCloseWindow;
 
            btnCloseWindow.addEventListener('click', function(){
                Ti.API.info('Close window');
                navWin.close();
 
            });
 
            if(e.action==='close')
            {
                Ti.API.info('Fire event: close window');
                navWin.close();     
            }
            else
            {
                navWin.open();
            }
 
        }
    );

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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