how to redirect from one page to tab in another page in titanium?

落花浮王杯 提交于 2019-12-11 23:14:46

问题


I have two pages in my application. The first page has a tab group with three tabs. Now on click of button in second page, I need to redirect my control to first tab 2 in my first page. How can I do that.

My code is as follows,

<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>

second page,

 <Alloy>
    <Window class="container">
                    <Button onClick="submitFun">submit</Button>
                </Window>
    </Alloy>


function submitFun()
{
var homeWindow = Alloy.createController('index').getView();
homeWindow.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});
}

I don't wat load the full index page because it will take long time to load. I need to load only one tab in the index page. How can I do that?


回答1:


I think you would have the code in index.js from where you open your second page; maybe like :

Alloy.createController('second').getView().open();

Now in second.js you can just call close method of the window to close current window and return back to index.

function submitFun()
{
   $.second.close(); //id of second window = second
}

Also now add a focus event listener in index.js for the tabgroup and navigate to the desired tab.

$.myTabGrp.addEventListener('focus',function(e) { 
   $.myTabGrp.setActiveTab($.two);
});


来源:https://stackoverflow.com/questions/27200731/how-to-redirect-from-one-page-to-tab-in-another-page-in-titanium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!