【问题标题】:Issue with open tab group in titanium钛中的打开标签组问题
【发布时间】:2014-11-05 10:33:59
【问题描述】:

我在一个标签组中有 4 个标签。单击选项卡名称时的选项卡转换工作正常。但是我需要在点击 tab3 中的按钮事件时从 tab3 打开 tab2。我怎样才能做到这一点。

示例代码,

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

【问题讨论】:

    标签: javascript iphone titanium titanium-mobile titanium-alloy


    【解决方案1】:

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

    首先我怀疑你的标签不能正常工作,因为它们没有包含在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);
    }
    

    编辑:要在 Tab 中重新加载/刷新窗口的内容,请在您的控制器中添加focus event of window

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

    希望对你有帮助。

    【讨论】:

    • 我不知道出于某种原因,如果我包含选项卡组的 id,我会收到应用程序错误。假设“未定义”不是 index.js (line2) 处的对象(评估“a.inex.open”)
    • 你应该使用$.myTabGrp.open();,因为根元素现在是标签组并且它有id = 'myTabGrp'
    • 太棒了。这是工作。但是在激活标签之前有什么方法可以重新加载。因为没有重新加载数据内容不会得到更新。
    • 我认为window's focus event 在这种情况下会有所帮助。
    • 是但是需要刷新,怎么刷新页面
    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-03
    相关资源
    最近更新 更多