calling destroy on templated widget not modifying dom

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

calling destroy on templated widget not modifying dom

I'm having issues destroying custom, templated widgets... calling widget.destroy() is removing the widget from the registry (and its parent's descendants array, if applicable), but is not removing the widget's dom nodes from the dom.

I'm approaching this under the assumption that widgets inheriting from dijit/_WidgetBase can be removed from the registry and purged from the dom by calling the widget.destroy() method... if that's not the case -- you can correct me right here :)

I've had this issue for some time, and have been hacking it ... would like to know what I'm doing wrong.

Simple example --

widget template

<div data-dojo-attach-point='domNode'>
  <div data-dojo-attach-point='left'></div>
  <div data-dojo-attach-point='center'>${cName}</div>
  <div data-dojo-attach-point='right'></div>

widget code

  function (declare, _WidgetBase, _TemplatedMixin, template){
    return declare([_WidgetBase, _TemplatedMixin],{
        var domNode = this.domNode;

let's assume that there's a dojox/mobile/ContentPane in the dom, var'd out as rBox

>> window.rBox = new ContentPane({id:'rBox'}).placeAt(document.body);

iterate over an array of data and create widgets 

>> var data = {"records":[{"cname":"Gary Kunz"},{"cname":"Bigham, Michael},{"cname":"Westlund, Michael"}]};

>> data.records.forEach(function(x){
      rBox.addChild(new simpleWidget({cName:x.cname}));

Still with me? Now - I can call rBox.destroyDescendants(); .... rBox.getChildren().forEach(function(child){child.destroy();}); .... I can get explicit references to the widget and call destroy on it directly... 

I get the same result. The widget(s) are removed from the registry (or the parent's child array), but the widget's dom representation is staring me in the face....

I have got to be missing something... anybody have any ideas?

Thanks all. Much appreciated.

- derek

Dojo Toolkit:

[hidden email]
To unsubscribe, visit: