![](/img/trans.png)
[英]Programmatic Dijit/Tree Not Appearing in Declarative Dijit/ContentPane
[英]dojo/dijit BorderContainer declarative example - but programmatic
我正在尝试以编程方式编写声明性示例,但到目前为止还没有成功。 http://dojotoolkit.org/reference-guide/dijit/layout/BorderContainer.html
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");
dojo.addOnLoad(function() {
var borderContainer = new dijit.layout.BorderContainer({
design: "sidebar",
gutters: true,
liveSplitters: true,
id: "borderContainer"
});
borderContainer.placeAt(dojo.body(), "last");
var panelLeft = new dijit.layout.ContentPane({
content: "<p>left</p>",
splitter: true,
region: "leading",
style: "width: 300px;"
});
panelLeft.placeAt("borderContainer", "first");
var panelRight = new dijit.layout.ContentPane({
content: "<p>right</p>",
splitter: true,
region: "center"
});
panelRight.placeAt("borderContainer", "last");
});
CSS 文件: #borderContainer { width: 100%; height: 100%; }
#borderContainer { width: 100%; height: 100%; }
你可以在这里看到代码: http://jsbin.com/inulig/27/edit#source
谢谢!
我发现http://blog.garethj.com/2010/08/programmatic-page-layouts-using-dojo-and-existing-markup/这给了我这个问题的线索。
我不得不使用borderContainer.addChild(contentPane)
而不是contentPane.placeAt(borderContainer, "last")
我会在这里留下答案,以防其他人也可能偶然发现这个问题。
borderContainer.addChild(contentPane);
borderContainer.startup(); //DO NOT FORGET TO STARTUP!!!
这样做: contentPane.placeAt(borderContainer.domNode, "last");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.