我有以下代码:
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();
});
提前感谢您的任何帮助
答案 0 :(得分: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/