【发布时间】:2012-09-04 09:11:44
【问题描述】:
我正在使用 Dojo Toolkit 开发一个移动应用程序。我有以下小部件:
define("js/custom/CustomHeading", [ "dojo/_base/declare", "dojo/dom-construct",
"dojo/dom-class", "dojox/mobile/Heading", "dojox/mobile/ToolBarButton",
"dojo/ready" ], function(declare, domConstruct, domClass, Heading,
ToolBarButton, ready) {
return declare("js.custom.CustomHeading", [ Heading ], {
buildRendering : function() {
this.inherited(arguments);
navigationButton = new dojox.mobile.ToolBarButton({
icon : "js/custom/images/navigation.png"
});
navigationButton.placeAt(this.domNode);
ready(function() {
console.log("I entered the block.");
});
}
});
});
如果我尝试使用 dijit.byId() 在我的 html 中查找一个小部件,我不会得到成功的结果。 Dojo 找不到小部件,但它在那里。我要查找的小部件如下所示:
<div id="navigationOverlay" data-dojo-type="dojox.mobile.Overlay">
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem"
data-dojo-props="moveTo:'dataServerRuntime',transition:'slide',label:'Health Summary'"
onclick="hideNavigation();"></li>
</ul>
</div>
我做错了什么?如何找到小部件?
【问题讨论】:
-
可能是时间问题 - 您是否检查过代码在 HTML 为 parsed 后是否运行?
-
在我的
data-dojo-config属性中我使用parseOnLoad: true。这不是解决时间问题吗?如果没有,我如何防止我的代码在 DOM 加载之前运行?
标签: dojo