0

次のタブ コントロールを使用しています。

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");
}

タブはアプリの起動時に正常に表示されます:

ここに画像の説明を入力

ただし、2 番目または 3 番目のタブのいずれかをクリックすると、両方とも最初のタブの上に移動します。

ここに画像の説明を入力

そして、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>

dojox.mobile.currentViewタブを切り替えた後に が何も返さない理由についてのアイデアはありますか?

4

1 に答える 1

1

これに関連していると思います: http://bugs.dojotoolkit.org/ticket/15040。最新バージョンの Dojo Mobile から dojox.mobile.currentView を削除したようです。私は現在 Worklight でいくつかの作業を行っていますが、dojox.mobile.currentView の「未定義」も取得しています。

そのページにはいくつかの推奨事項がありますが、すべてをより複雑にする必要があるようです - ええ :(

于 2012-08-23T12:55:58.923 に答える