我正在使用以下选项卡控件:

function tweetsAction()
{
    var w = dojox.mobile.currentView;
    if (w.id != "tweetsView") w.performTransition('tweetsView', 1, "slide", null);
}

function secondAction()
{
    var w = dojox.mobile.currentView;
    if (w.id != "secondView") w.performTransition('secondView', 1, "slide", null);
}

function thirdAction()
{
    var w = dojox.mobile.currentView;
    if (w.id != "thirdView") w.performTransition('thirdView', 1, "slide", null);
}
.

在Worklight JavaScript中初始化它们,例如:

function initCommonControls()
{
    console.log("Android initCommonControls");

    WL.TabBar.init();
    WL.TabBar.addItem("tweetsView", tweetsAction, "Tweets", {image:"images/icons/help_bw.png", imageSelected:"images/icons/help.png"});
    WL.TabBar.addItem("secondView", secondAction, "Second", {image:"images/icons/help_bw.png", imageSelected:"images/icons/help.png"});
    WL.TabBar.addItem("thirdView", thirdAction, "Third", {image:"images/icons/help_bw.png", imageSelected:"images/icons/help.png"});

    WL.TabBar.setSelectedItem("tweetsView");
}
.

选项卡在应用启动时显示:

但是,当我点击第二个或第三选项卡时,这两个都在第一个上移动:

,我在js控制台中看到这个javascript错误:

未捕获的TypeError:无法读取未定义

的属性'id'

这意味着`var w= dojox.mobile.currentview;关闭初始选项卡后无法获取当前视图。

这就是我的HTML的样子:

<!-- Tweets View -->
    <div id="tweetsView" data-dojo-type="dojox.mobile.ScrollableView" data-dojo-props="selected: true">
        <div class="spacing"></div>
        <h1 id="head0" data-dojo-type="dojox.mobile.Heading" 
            data-dojo-props="label:'Tweet Search', fixed:'top'"></h1>
        <button onclick="getTweets()">Get Tweets</button>
        <input data-dojo-type="dojox.mobile.TextBox" id="sampleItem">
        <ul data-dojo-type="dojox.mobile.EdgeToEdgeList" id="theTable"
            class="tweetviewList">
        </ul>
    </div>

    <!-- second View -->
    <div id="secondView" data-dojo-type="dojox.mobile.ScrollableView" data-dojo-props="selected:false">
        <div class="spacing"></div>
        <h1 data-dojo-type="dojox.mobile.Heading" 
            data-dojo-props="label:'second view', fixed:'top'"></h1>
        This is a second view
    </div>

    <!-- third View -->
    <div id="thirdView" data-dojo-type="dojox.mobile.ScrollableView" data-dojo-props="selected:false">
        <div class="spacing"></div>
        <h1 data-dojo-type="dojox.mobile.Heading" 
            data-dojo-props="label:'third view', fixed:'top'"></h1>
        This is a third view
    </div>
.

任何想法如何在切换选项卡后返回任何内容返回?

有帮助吗?

解决方案

我会猜测它与此相关: http://bugs.dojotoolkit.org/ticket/15040。听起来他们已经删除了Dojox.mobile.CurrentView从最新版本的Dojo Mobile。我目前正在用Worklight做一些东西,我也为Dojox.mobile.CurrentView获得“undefined”。

这个页面上有几个建议,但似乎现在一切都需要更复杂 - yay :(

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top