ISSUE WITH OPEN TAB GROUP IN TITANIUM

Maria Susan

Total Post:29

Points:107
Posted by  Maria Susan
JQuery 
 1265  View(s)
Ratings:
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

}

 

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: Issue with open tab group in titanium

    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.

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!