简体   繁体   English

未加载Dojo dijit.form.button

[英]Dojo dijit.form.button not loaded

I have the following code : 我有以下代码:

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();
});

All the layouts are loaded correctly but my button is not loaded. 所有布局均正确加载,但我的按钮未加载。

I tried to query #computer before the button.startup() call and it is loaded well. 我试图在button.startup()调用之前查询#computer,它已很好地加载。

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

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

button.startup();
});

thank you in advance for any help 预先感谢您的任何帮助

Don't create the button in markup 不要在标记中创建按钮

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

and just set the button widget as the content 然后将按钮小部件设置为内​​容

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

Here's a working example: http://jsfiddle.net/cswing/V6qK2/ 这是一个工作示例: http : //jsfiddle.net/cswing/V6qK2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM