0

我有以下代码:

require(["dijit/registry", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/form/Button", "dojo/query", "dojo/domReady!"], function(registry, BorderContainer,  ContentPane, Button, query){

var appLayout = new BorderContainer({
    design: "sidebar"
}, "appLayout");

var dataArea = new ContentPane({
    region: "center",
    content: '<div id="grid"></div>'
});

var actionArea = new ContentPane({
    region: "bottom",
    id: "actionarea",
    content: '<button id="computer"></button>'
});

var treeArea = new ContentPane({
    region: "left",
    id : "treearea",
    content: '<div id="treeroot"></div>',
    splitter: true
});

var button = new Button({
    label: "Load Computer tree"
}, "computer");

appLayout.addChild(treeArea);
appLayout.addChild(dataArea);
appLayout.addChild(actionArea);
appLayout.startup();
button.startup();
});

所有布局均已正确加载,但我的按钮未加载。

我试图在 button.startup() 调用之前查询#computer,它加载得很好。

appLayout.addChild(treeArea);
appLayout.addChild(dataArea);
appLayout.addChild(actionArea);
appLayout.startup();

console.log(query("#computer"));

button.startup();
});

预先感谢您的任何帮助

4

1 回答 1

1

不要在标记中创建按钮

var actionArea = new ContentPane({
    region: "bottom",
    id: "actionarea"
});

并将按钮小部件设置为内​​容

var button = new Button({
    label: "Load Computer tree"
}); 
actionArea.set('content', button);

这是一个工作示例:http: //jsfiddle.net/cswing/V6qK2/

于 2012-05-23T10:25:30.847 回答