如何在钛中从一个页面重定向到另一页面的选项卡? [英] how to redirect from one page to tab in another page in titanium?

查看:102
本文介绍了如何在钛中从一个页面重定向到另一页面的选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的申请中有两个页面.第一页具有一个包含三个选项卡的选项卡组.现在,单击第二页中的按钮,我需要将控件重定向到第一页中的第一个选项卡2.我该怎么办.

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.

我的代码如下,

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

第二页

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

推荐答案

我认为您可以在index.js中打开您的第二页中的代码;也许像:

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

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

现在在second.js中,您只需调用窗口的close方法即可关闭当前窗口并返回到index.

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
}

现在还添加一个 focus index.js中的tabgroup事件监听器,并导航到所需的tab.

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);
});

这篇关于如何在钛中从一个页面重定向到另一页面的选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆