Hi,
He is my problem,
var tb = new Draw(map);
tb.on("draw-end", lang.hitch(map, getAreaAndLength));
How can I later deactivate this handler ?
I wante something like : tb.on("draw-end").set(null) ??
This is because I have to switch between two handlers,
IF set directely the second handler it still call the first
so finally , it calls the two handlers.
Thanks,
Maxim
Maxim,
If you setup a variable for the event then you can just use the remove function.
var signal = tb.on("draw-end", lang.hitch(map, getAreaAndLength));
signal.remove();
Its:
tb.onDrawEnd.after.remove();
Maxim,
Maxim,
As with many things there are a couple of ways to do it. Don't forget to mark people responses as helpful (if you think they are) using the actions menu link. Also if you think that your answer is the best than mark yours as the correct answer.
Ok,
I tried to use directely tb.remove() but I am getting the exception that remove is not defined. So after seaching a while in the debugger options I found the remove funtion you suggested in onDrawEnd.after.remove();
Thanks Robert,
I think you should use once
Incidentally,
dojo/on
includes a convenience method for doing exactly this:on.once
. It accepts the same parameters ason
, but will automatically remove the handler once it is fired.