AnsweredAssumed Answered

onClick listener

Question asked by timw1984dev on Apr 28, 2014
Latest reply on Apr 29, 2014 by timw1984dev
Hey everybody,

I am playing around with an onClick listener and I am stuck. I am writing my whole application in AMD style.

For an easy example I just wanted an alert message to popup when I click on the map, when a button is toggled to true. When the button is toggled to false I don't want the alert to popup when I click the map.

Here is the code I have so far:

      var identifyListener;               function activateIdentify(){         if (dom.byId("identifyDiv").checked) {           identifyListener = map.on("click", executeIdentifyTask);         }          else {           identifyListener.remove();         }       }              function disableIdentify() {         dom.byId("identifyDiv").unchecked;         identifyListener.remove();       }              function executeIdentifyTask(){         alert("Click");       };

And here is the corresponding button:

<div id="Button1"><button id="identifyDiv" data-dojo-type="dijit/form/ToggleButton" data-dojo-props="iconClass:'dijitCheckBoxIcon', checked: false" onClick="activateIdentify();" >Identify</button> </div>

Thanks for any help!