Facebook login button and Navigation group

You must Login before you can answer or comment on any questions.

So I have a a preLogin.js which is create a navigation group. After login I put navGroup.close() and the navigation group is closed. If the user is logged out I include the preLogin.js and the nav group is created again. Everything was working fine until I enter this in preLogin.js:

var buttonLoginFB = Titanium.Facebook.createLoginButton({
         top: "90%",
         width: "70%",
         height: "12%",
        });
The navGroup is closing as before but when is create for the second time, if the user press the facebook login button the fb login listener is executed 2 times. If I log out again and I press fb login button is executed 3 times and so on. So, why the fb login button does not work as the other buttons? Why it remains there and is executed 2 or 3 times?

— asked 10 months ago by Michael Mavris
8 Comments
  • More details please? It sounds like you are adding the listener to the facebook button multiple times, or adding the facebook button multiple times.

    — commented 10 months ago by Josiah Hester

  • it's the facebook button that it added several times.here is the prelogin.js

    var buttonLoginFB = Titanium.Facebook.createLoginButton({
             top: "90%",
             width: "70%",
             height: "12%",         
            });
     
     
     
    var preLoginWin = Titanium.UI.createWindow({  
            titleImage:'/icons/logoForBar.png',     
            title:"Back",
            backgroundColor:'#fff',
            barColor:'00aeef',
           });
     
    other buttons....
     
    var navGroup = Ti.UI.iPhone.createNavigationGroup({
                            window:preLoginWin
            });
     
            preLoginWin.add(buttonLogin,buttonRegister,buttonLoginFB);
     
            var main = Ti.UI.createWindow();
     
            main.add(navGroup); 
            main.open();
     
        Ti.include('/code/loginFBC.js');
    here is the loginFBC.js:
    Ti.Facebook.addEventListener('login', function(e) {
     
     
          if (e.success) {
     
        some xhr.reguest
     
        xhr.onload = function(){
     
                        main.remove(navGroup);
                         navGroup.close();
     
                          //recreate the tabgroup
                     Ti.include('/view/tabGroup.js');
     
     
    }
    and this is the logout.js
    some xhr request
     
    if (reply="LOGOUT"){
     
     
                        tabGroup.close();
                        Ti.include('/view/preLogin.js');
     
     
                    }

    — commented 10 months ago by Michael Mavris

  • @michael a little bit of code snippet might help in understanding the issue !!

    — commented 10 months ago by Sahil Grover

  • Show 5 more comments

Your Answer

Think you can help? Login to answer this question!