Select to view content in your preferred language

how  to  stop event ?

2501
3
10-30-2012 02:10 AM
yanli
by
Emerging Contributor
i  have two  buttons,  name  btn1,btn2
    btn1  's  click  function{

   dojo.connect(map,"onclick",identify);

}

btn2  's  click  function{

   dojo.connnect(toolbar,"onDrawEnd",QueryinExtent)
}


My  question  is :
when  i  click btn1  first,then click btn2,but  the two  events  all  happen!!!!!!
when  I  use  toolbar draw event,  how  to  stop  the  map's  onclick  event?


help  help  help !!!!!!!1
0 Kudos
3 Replies
__Rich_
Deactivated User
i  have two  buttons,  name  btn1,btn2
    btn1  's  click  function{

   dojo.connect(map,"onclick",identify);

}

btn2  's  click  function{

   dojo.connnect(toolbar,"onDrawEnd",QueryinExtent)
}


My  question  is :
when  i  click btn1  first,then click btn2,but  the two  events  all  happen!!!!!!
when  I  use  toolbar draw event,  how  to  stop  the  map's  onclick  event?


help  help  help !!!!!!!1

I may have misinterpreted your issue but I think you might want to use dojo.disconnect to ensure you're only 'listening' to one of those events at a time.

(think of it like this:- you want to be in either Identify 'mode' OR Draw 'mode' but not both at the same time i.e. your aim is to make them mutually exclusive)
0 Kudos
SrikanthNarra
Emerging Contributor
I may have misinterpreted your issue but I think you might want to use dojo.disconnect to ensure you're only 'listening' to one of those events at a time.

(think of it like this:- you want to be in either Identify 'mode' OR Draw 'mode' but not both at the same time i.e. your aim is to make them mutually exclusive)


btn1 's click

function firstFunction(event){
event.preventDefault();
dojo.connect(map,"onclick",identify);

}

btn2 's click

function secondFunction(event){
event.preventDefault();
dojo.connnect(toolbar,"onDrawEnd",QueryinExtent)
}

Hope this may steer you to solve the problem
0 Kudos
ReneRubalcava
Honored Contributor
The link geos_rfleet provided has everything you need.
If you assign the connect method to a variable, you can disconnect it at a later time.
so
var handle = dojo.connect(item, 'event', function(){...});


then anywhere else in your code, you need to release that connected event
dojo.disconnect(handle);
0 Kudos