Adding Tags Programmatically

I have one container div id = "container", and I need to add labels to this div (10 or 4 or one - it depends on which button I click) and should look like a table (rows x 2 columns). How to achieve this? How to add tags programmatically?

+4
source share
3 answers

This is how I did it in dojo.

dojo.place('<label for="field">Field Name</label>', dojo.byId('widget_fieldId'), 'before'); 
+3
source

You can use the dojo.create function. For instance:.

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

where tableCellId is the identifier of the element to which you want to add a shortcut

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

+6
source

I found that I need to add a shortcut to the container before creating the TextEntry element, but it refers to the identifier of the TextEntry element.

The following is an example of adding a shortcut to an editor:

 var tabWizard = new TabContainer({ id : "tabWizard", class : "centerTabContainer", tabPosition : "left" }); var tab = new ContentPane({ title : "tabTitles", class : "tabPage" }); tabWizard.addChild(tab); var tabContainer = new BorderContainer({ design : 'headline', gutters : false }); var tabMain = new ContentPane( { id : "tabMain_What", class : "cdmMain", region : "center" }); tabMain.startup(); // here is where the label is created referencing the id details tabMain.domNode.appendChild( dojo.create("label",{ "for" : "details", innerHTML : "Details:" }) ); // here is the editor to be labeled as "Details:" var tabPrompt = new Editor({ id : "details", name : "details", class : "details" }); tabMain.addChild(tabPrompt); tabContainer.addChild(tabMain); tab.addChild(tabContainer); 
0
source

Source: https://habr.com/ru/post/1344900/


All Articles