我已经设置了简单的dojox / app移动应用程序,其中包含两个视图,列表和详细信息:
"defaultView": "list",
"views": {
"list": {
"controller": "comp/controller/list",
"template": "comp/view/list.html"
},
"details" : {
"controller": "comp/controller/details",
"template": "comp/view/details.html"
}
}
控制器正确显示ListItems中的列表,并且我已设置点击处理程序以转换到详细信息:
t.onClick = lang.hitch(t, function () {
this.transitionTo("details", 1, "slide", null);
});
但它不起作用。事实上,我看到列表变为蓝色约300毫秒,但然后保持相同的视图,没有控制台警告或错误。什么都没有。
还尝试在html中进行声明,但没有成功:
<div id="data" data-dojo-type="dojox/mobile/ScrollableView" data-dojo-props="selected: true">
<div id="dataHeading" data-dojo-type="dojox/mobile/Heading" data-dojo-props="fixed: 'top', label: 'All'">
<span data-dojo-type="dojox/mobile/ToolBarButton"
data-dojo-props="icon: 'img/settings.png'"
style="float:left;"></span>
<span id="refreshButton"
data-dojo-type="dojox/mobile/ToolBarButton"
data-dojo-props="icon: 'img/refresh.png', moveTo: 'details'"
style="float:right;"></span>
</div>
<div id="datasList" data-dojo-type="dojox/mobile/EdgeToEdgeList">
</div>
</div>
有任何帮助吗?谢谢
答案 0 :(得分:0)
文档有点混乱,至少对于dojo 1.9
为此找到了几个解决方案:
使用目标属性(而不是moveTo),因此上面的跨度将是
<span id="refreshButton"
data-dojo-type="dojox/mobile/ToolBarButton"
data-dojo-props="icon: 'img/refresh.png', target: 'details'"
style="float:right;"></span>
或代码
var t = new ListItem(data);
t.target = "details";
您使用dojox/app
transitionToView
函数
beforeActivate: function (previousView, data) {
(...)
var t = new ListItem(data);
//t.target = ""; this will be handle in the onClick event
t.clickable = true;
t.placeAt(this.list, "last");
t.onClick = lang.hitch(this, function () {
this.app.transitionToView(this.domNode, {
target: "details" });
});
}
或通过TransitionEvent模块,这似乎是正确的方式
beforeActivate: function (previousView, data) {
(...)
var t = new ListItem(data);
//t.target = ""; this will be handle in the onClick event
t.clickable = true;
t.placeAt(this.list, "last");
t.onClick = lang.hitch(this, function () {
new TransitionEvent(this.domNode, {
target: "details",
transition: "slide",
transitionDir: 1
}).dispatch();
});
}