Select to view content in your preferred language

Disable all event listeners

848
3
03-15-2013 01:35 AM
SaiDake
Emerging Contributor
Hi, I have a listner for event "onclick". Implementation of that listner zooms map to a certain point and renders graphics on it. No again on click of that zoomed in graphics,i want an other onclick event lisetner. Since the existing onclick event listner is already active, it zooms in again. I want to disconnect the existing onclick lisetner and have a new listener inside it. dojo.discoonect(abc)  is not working, since the abc is nt accessible due to out of scope. Is there any common thing which disconnects all event listeners?
0 Kudos
3 Replies
DavideLimosani
Frequent Contributor
Hi, I have a listner for event "onclick". Implementation of that listner zooms map to a certain point and renders graphics on it. No again on click of that zoomed in graphics,i want an other onclick event lisetner. Since the existing onclick event listner is already active, it zooms in again. I want to disconnect the existing onclick lisetner and have a new listener inside it. dojo.discoonect(abc)  is not working, since the abc is nt accessible due to out of scope. Is there any common thing which disconnects all event listeners?



I think you can do this:
    var handler = dojo.connect(map, "onClick", function () {

      
        dojo.disconnect(handler);

          //stuff
          });

0 Kudos
SaiDake
Emerging Contributor
Thx!! It worked. However, i made afunction call and wen im trying to do that iin the function call, it says out of scope.
0 Kudos
JeffPace
MVP Alum
try

var handler = dojo.connect(map, "onClick", dojo.hitch(this, function () {

     
        dojo.disconnect(handler);

          //stuff
          }));
0 Kudos