Pergunta

Existe uma maneira de criar e anexar um dijit ao final de uma div? Digamos que eu tenha o seguinte código:

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

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

Eu encontrei o seguinte código online, mas isso substitui a minha div 'assistentes':

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

e eu quero adicionar dinamicamente um novo dijit TextBox ao div, não substitui o div com um dijit.

Foi útil?

Solução

A resposta é: 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");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top