Select to view content in your preferred language

is it possible to disconnect an onClick event listener?

4692
3
11-09-2010 04:19 AM
BradCochran
Emerging Contributor
basically i want to enable and disable the onClick listener at will.  is this possible?

i see where you can do a dojo.disconnect(map, "onClick"); on unload but I want to be able to turn it on and off via a function. 

if this isn't possible are there any other creative solutions to this problem?  i can achieve the desired effect I am after by just hiding the div that is getting the results from my onclick event, but this seems like a waste of resources.

thanks in advance.
0 Kudos
3 Replies
derekswingley1
Deactivated User
dojo.connect returns a handle that you can use to disconnect the event listener. Use something like this in your code:

var map_click_handle = dojo.connect(map, 'onClick' some_function);
dojo.disconnect(map_click_handle);


Of course that's a simplified example... Check out the docs for dojo.connect and dojo.disconnect.
AxelSchaefer
Emerging Contributor
Please read the Concepts part of the ArcGIS Server JS-API documentation: Working with events
0 Kudos
BradCochran
Emerging Contributor
awesome thanks!
0 Kudos