Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add labels programmatically

Tags:

dojo

I have one div id="container" container and I need to add labels to that div ( 10 or 4 or one - depends which button I click ) and need to look like table ( rows x 2 column ). How to achieve this ? How to add labels programmatically ?

like image 335
Damir Avatar asked Mar 23 '11 09:03

Damir


People also ask

What is UILabel in Swift?

A view that displays one or more lines of informational text.


2 Answers

You can use dojo.create function. E.g.:

var label = dojo.create("label", {for:"fieldId", innerHTML:"SomeText"}, "tableCellId");

where tableCellId - id of the element in which you want to append label

Similarly you can dynamically create a table, and add labels to a new table.

var table = dojo.create("table", null, dojo.body());
var row = dojo.create("tr", null, table);
var cell = dojo.create("td", null, row);
var label = dojo.create("label", {for:"fieldId", innerHTML:"SomeText"}, cell);

Dojo create documentation

like image 142
Andrei Avatar answered Sep 23 '22 00:09

Andrei


Here's how I've been doing it in dojo.

dojo.place('<label for="field">Field Name</label>', dojo.byId('widget_fieldId'), 'before');
like image 26
Richard Ayotte Avatar answered Sep 24 '22 00:09

Richard Ayotte