1

我正在尝试以编程方式编写声明性示例,但到目前为止还没有成功。 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%; }

你可以在这里看到代码:http: //jsbin.com/inulig/27/edit#source

谢谢!

4

3 回答 3

5

我发现http://blog.garethj.com/2010/08/programmatic-page-layouts-using-dojo-and-existing-markup/这给了我这个问题的线索。

我不得不使用borderContainer.addChild(contentPane)而不是contentPane.placeAt(borderContainer, "last")

我会在这里留下答案,以防其他人也可能偶然发现这个问题。

于 2011-07-21T09:01:01.057 回答
1
borderContainer.addChild(contentPane);
borderContainer.startup(); //DO NOT FORGET TO STARTUP!!!
于 2013-11-07T19:59:15.933 回答
0

这样做: contentPane.placeAt(borderContainer.domNode, "last");

于 2012-07-11T04:20:30.077 回答