From 1cdeeccab0e76495842cad9d04e686aee802777d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 9 Nov 2012 12:54:33 -0500 Subject: [PATCH] Widget: Suppress disabled check when binding destroy to the remove event. Fixes #8769 - Widget: ui-state-disabled blocks destroy to be triggered on remove. --- tests/unit/widget/widget_core.js | 6 ++++++ ui/jquery.ui.widget.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index b0812638a..418cc4d39 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -1197,6 +1197,12 @@ test( "._trigger() - instance as element", function() { }); }); + test( "auto-destroy - .remove() when disabled", function() { + shouldDestroy( true, function() { + $( "#widget" ).testWidget({ disabled: true }).remove(); + }); + }); + test( "auto-destroy - .remove() on parent", function() { shouldDestroy( true, function() { $( "#widget" ).testWidget().parent().remove(); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 65ac155ae..02f89bc98 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -232,7 +232,7 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetFullName, this ); - this._on( this.element, { + this._on( true, this.element, { remove: function( event ) { if ( event.target === element ) { this.destroy();