Select to view content in your preferred language

Listening to a checkbox

1745
2
Jump to solution
10-17-2017 12:46 PM
KenBuja
MVP Esteemed Contributor

I'm adding a checkbox on my widget that turns labels on or off on a particular layer. However, it doesn't respond to the click event "showCoinLabels" as defined in data-dojo-attach-event

<div data-dojo-type="jimu/dijit/CheckBox" data-dojo-attach-point="chkCoinLabels" style="margin-top: 5px;" data-dojo-attach-event="onClick: showCoinLabels"></div><label class="jimu-leading-margin05">Show Coin Labels</label>

If I substitute a jimu-btn, that will fire the event

<div data-dojo-attach-point="btntest" id="chkCoinLabels" class="jimu-btn apply" data-dojo-attach-event="onclick:showCoinLabels" style="margin-top: 10px">Show Coin Labels</div>

I've also tried using a regular data-dojo-type="dijit/form/CheckBox", as used in the Analysis widget Setting.html, with no luck. What's the proper way to add a checkbox?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ken,

   The jimu/dijit/CheckBox does not have an onClick event. Here is what I use:

//in your Widget.js
this.chkCoinLabels.onChange = lang.hitch(this, this.showCoinLabels);‍‍

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Ken,

   The jimu/dijit/CheckBox does not have an onClick event. Here is what I use:

//in your Widget.js
this.chkCoinLabels.onChange = lang.hitch(this, this.showCoinLabels);‍‍
KenBuja
MVP Esteemed Contributor

Thanks, Rob. That explains why some widgets use jimu/dijit/CheckBox and others use dijit/form/CheckBox. I shouldn't have assumed they had the same capabilities.

0 Kudos