Reputation: 15476
Is there a way to create and append a dijit to the end of a div? Say I have the following code:
<div id="attendants">
</div>
<button dojoType="dijit.form.Button" onClick="addPerson();">Add Person</button>
I found the following code online but this replaces my 'attendants' 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);
}
and I want to dynamically add a new TextBox dijit to the div, not replace the div with a dijit.
Upvotes: 0
Views: 4344
Reputation: 1878
The answer is: 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");
Upvotes: 2