Search code examples
javascripttitaniumappceleratorappcelerator-mobiletitanium-mobile

Titanium: Why TabGroup's tabs does not Changing / Working?


I have a tabGroup and it holds 3 tabs.

Code in app.js:

// create tab group
var tabGroup = Titanium.UI.createTabGroup(
{ 

//tabBarHidden:false
});

        var win1 = Titanium.UI.createWindow({  
        url:'TabClasses/Tab1/Tab1.js',
        navBarHidden:true                    
    });
    var tab1 = Titanium.UI.createTab({  
        icon:'KS_nav_views.png',
        title:'Friend List',

        window:win1
    });

    var win2 = Titanium.UI.createWindow({        
        url:'TabClasses/Tab2/SearchView.js'
    });
    var tab2 = Titanium.UI.createTab({  
        icon:'KS_nav_ui.png',
        title:'Search',

        window:win2
    });

    var win3 = Titanium.UI.createWindow({            
        url:'TabClasses/Tab2/FindView.js'
    });
    var tab3 = Titanium.UI.createTab({  
        icon:'KS_nav_ui.png',
        title:'Places',
        window:win3
    });

//  add tabs

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addTab(tab3);

loginBtn.addEventListener('click',function(e)
{
    if (true)
     {
        tabGroup.open
        ({
            transition: Titanium.UI.iPhone && Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
        });
     } 
});

But when I click on different tabs , the tabs changes only once. Means when I click on tab 2 from tab 1 it changes but when I go back to tab 1 then it does not change and remains tab 2 's screen.

How can I solve this issue ?

Also it works Fine in Android !!!

Thanks...


Solution

  • Don't create and open a new window in your .js file. You should use current window like

    var currentWindow = Titanium.UI.currentWindow