Skip to content

Instantly share code, notes, and snippets.

@gabriel403
Created August 28, 2012 11:54
Show Gist options
  • Save gabriel403/3497500 to your computer and use it in GitHub Desktop.
Save gabriel403/3497500 to your computer and use it in GitHub Desktop.
Creating a label for a dojo widget
var container = domConstruct.create("div", {'id':'TreeEditContainer'}, win.body());
var form = new Form().placeAt(container);
var langSelect = new Select({
name: "LanguageSelect",
options: [
{ label: "en_gb", value: "en_gb" }
]
});
var label = new Label({'widget':langSelect,'container':form, 'label':'Some label'});
label.makelabel();
define(["dojo/_base/declare", "dojo/_base/lang", "dojo/dom-construct"], function(declare, lang, domConstruct){
return declare([ ], {
constructor: function(props) {
lang.mixin(this, props);
},
widget: null,
container: null,
label: null,
subcontainerType: 'div',
subcontainer: null,
makelabel: function(){
this.subcontainer = domConstruct.create(this.subcontainerType, {}, this.container.id);
domConstruct.create("label", {"for": this.widget.id, 'innerHTML': this.label}, this.subcontainer);
this.widget.placeAt(this.subcontainer);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment