dojo / dijit BorderContainer声明性示例 - 但是程序化

时间:2011-07-20 10:14:32

标签: javascript dojo dijit.layout

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

谢谢!

3 个答案:

答案 0 :(得分:6)

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

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

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

答案 1 :(得分:1)

borderContainer.addChild(contentPane);
borderContainer.startup(); //DO NOT FORGET TO STARTUP!!!

答案 2 :(得分:0)

DO THIS:contentPane.placeAt(borderContainer.domNode,“last”);