我正在使用以下标签控件:
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>
关于切换标签后dojox.mobile.currentView
为什么没有返回任何内容的任何想法?
答案 0 :(得分:1)
我猜它与此有关:http://bugs.dojotoolkit.org/ticket/15040。听起来他们已经从最新版本的Dojo Mobile中删除了dojox.mobile.currentView。我目前正在使用Worklight做一些事情,而且我也为dojox.mobile.currentView获取'undefined'。
该页面上有几条建议,但现在看来一切都需要复杂得多 - yay :(