I have created a widget in Aikau and the idea is that inside of it, there is only one widget in any moment and it swaps from one type to another dynamically.
My procedure is the follow:
- I delete all the widgets inside of the father widget
- I construct the new widget.
Right now my code works, but I don't know if I am eliminating all the widgets children properly. I didn't find any function in the documentation to do it:
swapWidget: function myPackage_myWidget__swapWidget(event) {
// REMOVE ALL THE CHILDREN
// is it this ok?
$(this.domNode).find('div').remove();
var widgetId = event.widgetId
, widget = this.widgetsPosibilities[widgetId]
, clonedWidgets = lang.clone([widget])
;
this.processWidgets(clonedWidgets, this.domNode);
},
postCreate : function myPackage_myWidget__postCreate() {
var event = {widgetId: this.initWidgetId};
this.jumpWidget(event);
this.alfSubscribe('MY_CUSTOM_EVENT', lang.hitch(this, this.swapWidget));
this.inherited(arguments);
}
It is enough "$(this.domNode).find('div').remove();" to eliminate all the children widgets?
In general I prefer to use JQuery, but maybe the right way is to using Dojo.
What is best way?
What will last for longer with in new releases of Aikau?