UI-widget destroy() method.
Hey guys;
I am writing a widget, and I have a question about my destroy() method:
destroy: function() {
// revert DOM to original state ...
this.element.unbind(); // expected $.widget to do this!
$.widget.prototype.destroy.apply(this, arguments); // default destroy
}
This is my code, with the revert bit removed for clarity.
I want to call $widgetHandle.mywidget("destroy"); manually, which works, but the events still have references to the widget. I have to manually .unbind() to remove all the events with references that are are stale. The stale calls happen on remove of the original node, which should now be un-widget-ed.
I expected the default destroy to unbind the events it makes. Is there a similar issue with widget data left in the .data() space somewhere? I want to be able to generate a completely new widget instance on the same node, so I can't have hangovers from the old widget instance ..
Hope I make sense :)
<br clear="all">
--
Tim Taylor
--