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

本文是小编为大家收集整理的关于如何在titanium中从一个页面重定向到另一个页面的标签?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在我的应用程序中有两页.第一个页面有一个带有三个选项卡的选项卡组.现在在第二页中点击按钮,我需要将我的控件重定向到我的第一页中的第一个选项卡2.我怎样才能做到这一点.

我的代码如下,

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

我不加载完整索引页面,因为它需要很长时间才能加载.我需要只加载索引页面中的一个选项卡.我该怎么做?

推荐答案

我认为您可以在index.js中有代码从您打开第二页;也许喜欢:

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

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

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

现在也添加了一个 focus index.js中的事件侦听器为tabgroup并导航到所需的tab.

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

本文地址:https://www.itbaoku.cn/post/1938233.html

问题描述

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?

推荐答案

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