Dojo can't programmatically concatenate djits?

不打扰是莪最后的温柔 提交于 2019-12-02 02:43:37

You are mixing up Dijit objects, DOM nodes and strings.

The corrent way to place Dijits into Dialog or any container widget is:

dojo.place(button1.domNode, d.containerNode);
dojo.place(button2.domNode, d.containerNode);
d.show();

Or you can call placeAt() method when creating Dijit object:

var button1 = new dijit.form.Button({'label': 'one', 'onClick': function () {
    alert('one')
}}).placeAt(d.containerNode);

You got your result because what basically happens is

d.attr("content", button1.toString() + '|' + button2.toString());

Also note inserting strings is possible this way:

var button1Html = dojo.create("div").appendChild(button1.domNode).parentNode.innerHTML;
var button2Html = dojo.create("div").appendChild(button2.domNode).parentNode.innerHTML;
d.set("content", button1Html + "|" + button2Html);

but it won't work, because it creates new DOM nodes that are not referenced in Dijit objects (buttons), so your events won't fire.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!