Dojo: Setting a CheckBox label programmatically

Posted by Mitchell Flaherty on Stack Overflow See other posts from Stack Overflow or by Mitchell Flaherty
Published on 2012-06-20T21:13:34Z Indexed on 2012/06/20 21:15 UTC
Read the original article Hit count: 178

Filed under:
|
|
|
|

Let me preface by saying that I saw this other question on the subject of CheckBox labels that was asked and answered well over a year ago.

I was confused by the answers and am hoping that someone can clarify or that there has been new dojo functionality introduced since then that allows me to do this without resorting to HTML.

So without further ado, I would like to know how to programmatically create labels for check boxes.

I have a check box like so:

        this.pubBoxId = new dijit.form.CheckBox({
            label: "IdChannel",
            checked: false,
            channel: that.idChannel
        }, that.name + "_PBI");

As you can see I've tried to edit the "label" field, but the label never actually shows up on the page. I have multiple CheckBoxes that I am adding to a ContentPane and simply want a label to the left or right of the check box. Is there any way I can do this without having to write separate HTML?

Also, making a separate ContentPane for each individual label would be a big pain because of how many CheckBoxes I plan to have.

Thank you for reading, and let me know if further clarification is needed!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about checkbox