钛合金开口标签组存在问题

Issue with open tab group in titanium

本文关键字:存在 问题 标签 钛合金      更新时间:2023-09-26

我在一个选项卡组中有4个选项卡。单击选项卡名称时的选项卡转换工作正常。但我需要在点击选项卡3中的按钮事件时从选项卡3打开选项卡2。我该怎么做。

样本代码,

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

控制器:

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
}

我目前不在我的系统上,我可以提到的问题/评论仍然很少:

首先,我怀疑你的标签不会正常工作,因为它们没有包含在TabGroup中。

所以你的观点应该是:

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

现在,当saveLang方法在控制器中被调用时,我们可以调用setActiveTab方法:

function saveLang() {
  $.myTabGrp.setActiveTab($.two);
}

编辑:要重新加载/刷新选项卡中窗口的内容,请在控制器中添加窗口的焦点事件

$.winTwo.addEventListener('focus',function(e) { 
    alert('focus');
});

希望有帮助。