AnsweredAssumed Answered

widget question: destroy event?

Question asked by kmsagis on May 14, 2015
Latest reply on May 14, 2015 by kmsagis

I want to remove the click handler in my Pictometry widget if the user closes the widget. Regardless whether they've already clicked on the map. (I already have the covered, after the, the next line is handlerPictometry.remove() )  Because currently the map.on 'click' handler stays active until the map is clicked on. I want to remove it when the widget closes.


Oddly enough Dojo docs do not talk about hooking to a widget closing.

I referred to Understanding _WidgetBase - Dojo Toolkit Tutorial  and Writing Your Own Widget — The Dojo Toolkit - Reference Guide  etc


But I found this useful thread, the aspect.after post: javascript - Do dojo widgets emit an event when destroyed or can you force one to? - Stack Overflow 


So I figured I should be able to just do this code below, right?  It doesn't fire. Neither does using this.on or this.own(on

or other Dojo-recommended patterns.  And I made sure I required all the right modules etc. No console errors. It just doesn't fire. In terms of where it'd be, it's just inside the "clazz" in my Pictometry widget I posted on here.  I'll continue working on this. I want to get this working before posting my widget update which has some of the other new stuff, too.


I'm new to writing widgets and this is my first so it could likely be something simple.


  startup: function () {


         aspect.after(this, 'destroy', function () {
   alert('destroyed'); //or..handlerPictometry.remove();

}, true);