将动态生成的dijit追加到div的末尾

时间:2009-03-04 21:56:50

标签: javascript dojo

有没有办法在div的末尾创建并附加dijit?说我有以下代码:

<div id="attendants">
</div>

<button dojoType="dijit.form.Button" onClick="addPerson();">Add Person</button>

我在网上找到了以下代码,但这取代了我的'服务员'div:

var personCount = 0;
function addPerson() {
    personCount += 1;
    var attendants = dojo.byId('attendants');
    var newField   = new dijit.form.TextBox({id: 'newPerson' + personCount, name: 'newPerson' + personCount}, attendants);
}

我希望动态地将新的TextBox dijit添加到div中,而不是用dijit替换div。

1 个答案:

答案 0 :(得分:2)

答案是:dijit._Widget.placeAt

// place a new button as the first element of some div
var button = new dijit.form.Button({ label:"click" }).placeAt("wrapper","first");