I need to add dynamically HTML labels
before each ValidationTextBox
.
ValidationTextBox
and HTML label are created accordingly to the number of property present for object data
.
I would need an example on how to do it.
Example: http://jsfiddle.net/F2qAN/97/#run
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.layout.ContentPane");
function build() {
var data = {
name: 'a',
surname: 'b',
age: 'c'
},
validationTextBox,
layout = new dijit.layout.ContentPane({});
Object.keys(data).forEach(function (prop, index) {
validationTextBox = new dijit.form.ValidationTextBox({
id: prop + '-'+ index,
name: prop,
value: data[prop]
});
layout.addChild(validationTextBox);
}.bind(this))
layout.placeAt('layout');
layout.startup();
}
dojo.addOnLoad(build);
I am trying using dojo/dom-construct
but with no result, ex:
var label = domConstruct.toDom("<label for="male">label</label>");
layout.addChild(validationTextBox);
layout.addChild(label );
I found a solution using dojo.place().
Still interested to understand are there alternative ways to achieve the same result.
http://jsfiddle.net/F2qAN/101/
Using a home made widget is the proper approach for that.