HTML shortcut not showing (Dojo 1.8)

I am creating a set of checkboxes dynamically using Dojo 1.8. By creating this checkbox, I also set the label for this checkbox, but the shortcut is not displayed on the site, although I can see it when I look at the HTML in Firebug. Any ideas what I am doing wrong? I have been looking at the code for too long and cannot figure out what it is. Thank!

var checkboxContainer = dom.byId('divLayers');
var chkboxId = 'chk' + layer.id;
var chkbox = new dijit.form.CheckBox({
    id: chkboxId,
    checked: layer.visible,
    onClick: lang.hitch(this, this.toggleLayerVisibility)
});
chkbox.placeAt(checkboxContainer);
chkbox.domNode.appendChild(domConstruct.create('label', { 'for': chkboxId, innerHTML: layer.name }));

      

+3


source to share


1 answer


I swear I can spend hours trying to figure something out and then the moment I post it online for everyone to see, I solve my problem. swinging head

The solution is below.



var chkboxId = 'chk' + layer.id;
var chkbox = new dijit.form.CheckBox({
    id: chkboxId,
    checked: layer.visible,
    onClick: lang.hitch(this, this.toggleLayerVisibility)
});
chkbox.placeAt(checkboxContainer);
var lbl = domConstruct.create('label', {
    'for': chkboxId,
    'innerHTML': layer.name
});
checkboxContainer.appendChild(lbl);

      

+2


source







All Articles