한 탭에서 다른 탭으로 이동한 후 dojox.mobile.currentView가 널입니다.
-
12-12-2019 - |
문제
다음 탭 컨트롤을 사용하고 있습니다.
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 오류가 표시됩니다.
잡히지 않은 유형오류:정의되지 않은 '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
탭을 전환한 후 아무것도 반환하지 않습니까?
해결책
나는 이것이 이것과 관련이 있다고 추측합니다 : http://bugs.dojotoolkit.org/ticket/15040.최신 버전의 Dojo Mobile에서 dojox.mobile.currentView를 제거한 것 같습니다.현재 Worklight로 몇 가지 작업을 수행하고 있는데 dojox.mobile.currentView에 대해서도 '정의되지 않음'이 표시됩니다.
해당 페이지에는 몇 가지 권장 사항이 있지만 이제 모든 것이 훨씬 더 복잡해져야 할 것 같습니다. 예:(
제휴하지 않습니다 StackOverflow