Search code examples
dojo2

Dojo 2 How can I destroy dojo 2 widget manually?


This question is specific to Dojo 2 not dojo 1


Solution

  • onDetach is called when a widget is removed from the widget tree and therefore the DOM. onDetach is called recursively down the tree to ensure that even if a widget at the top of the tree is removed all the child widgets onDetach callbacks are fired.

    class MyClass extends WidgetBase {
      onDetach() {
        // do things when removed from the DOM
      }
    }