r3544 committed - Widget factory: Destroy widget when the main element is removed from t...
Revision: 3544
Author: scott.gonzalez
Date: Mon Dec 28 07:51:04 2009
Log: Widget factory: Destroy widget when the main element is removed from
the DOM.
http://code.google.com/p/jquery-ui/source/detail?r=3544
Modified:
/branches/dev/ui/jquery.ui.widget.js
=======================================
--- /branches/dev/ui/jquery.ui.widget.js Sun Dec 27 21:48:13 2009
+++ /branches/dev/ui/jquery.ui.widget.js Mon Dec 28 07:51:04 2009
@@ -113,11 +113,19 @@
$[this.namespace][this.widgetName].defaults,
$.metadata && $.metadata.get(element)[this.widgetName],
options);
+
+ // TODO: use bind's scope option when moving to jQuery 1.4
+ var self = this;
+ this.element.bind('remove.' + this.widgetName, function() {
+ self.destroy();
+ });
+
(this._init && this._init(options, element));
},
-
+
destroy: function() {
this.element
+ .unbind('.' + this.widgetName)
.removeData(this.widgetName)
.removeAttr('aria-disabled')
.removeClass(
--