Home > DeveloperSection > Forums > Issue with open tab group in titanium
Maria Susan

Total Post:29

Points:107
Posted on    November-24-2014 10:12 PM

 JavaScript JQuery 
Ratings:


 1 Reply(s)
 975  View(s)
Rate this:

I have 4 tabs in a tab group. The tab transition on click of tab names is working fine. But I need to open tab2 from tab3 on click of button event in tab3. How can I do that.

Sample code,

<Alloy>

<Tab id="one">

    <Window class="container">

        <Label>This is the Home View</Label>

    </Window>

</Tab>

<Tab id="two">

    <Window class="container">

        <Label>This is the second View</Label>

    </Window>

</Tab>

<Tab id="three">

    <Window class="container">

        <Button onClick="saveLang">Proceed</Button>

    </Window>

</Tab>

 

</Alloy>

Controller:

function saveLang()

{

// How can we open only tab2 here

// I tried open index, the loading time taking long and also it is opening tab1 But I need to open tab2 for this event

}

 



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    November-25-2014 2:12 AM

I am not currently on my system , still few issues/comments which I can mention are :

Firstly I doubt your tabs would not work properly as they are not enclosed in TabGroup.

So your view should be like :

<Alloy>

  <TabGroup id="myTabGrp"> //Tabgroup Added

    <Tab id="one">

        <Window class="container">

            <Label>This is the Home View</Label>

        </Window>

    </Tab>

 

    <Tab id="two">

        <Window class="container" id="winTwo">

            <Label>This is the second View</Label>

        </Window>

    </Tab>

 

    <Tab id="three">

        <Window class="container">

            <Button onClick="saveLang">Proceed</Button>

        </Window>

     </Tab>

  </TabGroup>

</Alloy>

Now when saveLang method gets called in controller we can call setActiveTab method:

function saveLang() {

  $.myTabGrp.setActiveTab($.two);

}

Edit : For reloading/refreshing content of a window in Tab , add focus event of window in your controller:

$.winTwo.addEventListener('focus',function(e) {

    alert('focus');

});

Hope it is helpful.

 


Don't want to miss updates? Please click the below button!

Follow MindStick