【问题标题】:how to redirect from one page to tab in another page in titanium?如何在钛中从一个页面重定向到另一个页面中的选项卡?
【发布时间】:2014-11-29 09:22:01
【问题描述】:

我的应用程序中有两个页面。第一页有一个包含三个选项卡的选项卡组。现在单击第二页中的按钮,我需要将控件重定向到第一页中的第一个选项卡 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});
}

我不会加载完整的索引页面,因为加载需要很长时间。我只需要在索引页面中加载一个标签。我该怎么做?

【问题讨论】:

    标签: titanium titanium-mobile appcelerator titanium-alloy appcelerator-mobile


    【解决方案1】:

    我认为您会在index.js 中获得代码,您可以从那里打开第二页;也许像:

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

    现在在second.js你可以调用窗口的close方法来关闭当前窗口并返回到index

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

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

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

    【讨论】:

    • 正确,现在我也是这样做的。但我需要重新加载焦点标签。有一些复选框在显示页面之前我需要清除所有选定的值。我该怎么做
    • 已在您的another question 中回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    • 2011-08-22
    • 2016-12-14
    • 1970-01-01
    相关资源
    最近更新 更多