如何重新加载钛合金选项卡组中的选项卡 [英] How to reload the tab in tab group in titanium alloy

查看:28
本文介绍了如何重新加载钛合金选项卡组中的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标签组中有三个标签.一个选项卡用于更改语言.如果用户更改语言,我应该需要更改所有选项卡的选定语言.我的标签组代码如下,

I have three tabs in my tab group. One tab is for change language. If user changes the language I should need to change the selected language for all the tabs. my tab group 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>

所有 ui 文本都从数据库中丢失.那么如何在tab3中的继续按钮的时钟上重新加载选项卡.

All the ui text is losing from database. So How can I reload the tab on clock of proceed button in tab3.

我尝试了以下代码,

function saveLang() {
  $.myTabGrp.setActiveTab($.two);
}
$.winTwo.addEventListener('focus',function(e) { 
   // How can I reload the tab2 here....
alert('focus');
});

如果我尝试以下代码,一切正常,但是加载时间太长,它将结构化 3 秒,然后加载所需的输出.我需要避免长时间的加载.

If I try the following code everything is working fine but, It is taking too long to load it will struct for 3 sec and then loading the required output. I need to avoid the long loading time.

var homeWindow = Alloy.createController('index').getView();
homeWindow.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});

关于如何以更少的加载时间重新加载标签的任何建议..

Any suggestions that how can we reload the tab with less loading time..

推荐答案

您的问题的某些部分已在这里(如何从一个页到另一个钛页中的标签?).

Some part of your question answered here ( how to redirect from one page to tab in another page in titanium? ).

当您切换到选项卡二或 winTwo 或当您打开 tabGroup 时,您会调用一些函数来更新您的窗口 UI.也许你会在 index.js 中有如下内容:

When you switch to tab two or winTwo or when you open tabGroup, there would be some function which you call to update your window UI. Maybe you will have something like following in index.js :

$.myTabGrp.open();
updateWin1();
updateWin2();
updateWin3();

function updateWin1() {
  var value = "Win1"; //fetched from local db
  $.win1Label.text = value;
}

function updateWin2() {
  var value = "Win2"; //fetched from local db
  $.win2Label.text = value;
}

function updateWin3() {
  var value = "Win3"; //fetched from local db
  $.win3Label.text = value;
}

现在在 winTwo 的焦点 EventListener 中调用 updateWin2 方法(如下所示):

Now in your winTwo's focus EventListener call the updateWin2 method ( like following ):

$.winTwo.addEventListener('focus',function(e) { 
  //Reloaded
  updateWin2();
});

注意:您可以根据您的要求在方法 updateWin2() 中进行任何复杂的 UI 操作.

Note : You can have any complex amount of UI manipulation in the method updateWin2(), according to your requirement.

PS:如果您使用的是 Alloy 模型和集合概念,您应该尝试 合金数据绑定.

P.S : If you are using Alloy models and collection concept, you should try Alloy Data Binding.

这篇关于如何重新加载钛合金选项卡组中的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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