aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.widget.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2010-09-03 09:49:29 -0400
committerScott González <scott.gonzalez@gmail.com>2010-09-03 09:49:29 -0400
commit0a0a39f896f83412dc91bedd6819c3a3a0932302 (patch)
treeb6ae6d6a9639b16f5f709f9ca95a0ccba40f086f /ui/jquery.ui.widget.js
parente5f3bfce4d2f761eea536d61f1282beca19fc774 (diff)
downloadjquery-ui-0a0a39f896f83412dc91bedd6819c3a3a0932302.tar.gz
jquery-ui-0a0a39f896f83412dc91bedd6819c3a3a0932302.zip
Widget: Hook into jQuery.cleanData to auto-destroy widgets. Fixes #6008 - Widget: auto-destroy is broken in jQuery 1.4.
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r--ui/jquery.ui.widget.js36
1 files changed, 23 insertions, 13 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index d08dbb81f..dbfea2574 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -9,20 +9,30 @@
*/
(function( $, undefined ) {
-var _remove = $.fn.remove;
-
-$.fn.remove = function( selector, keepData ) {
- return this.each(function() {
- if ( !keepData ) {
- if ( !selector || $.filter( selector, [ this ] ).length ) {
- $( "*", this ).add( [ this ] ).each(function() {
- $( this ).triggerHandler( "remove" );
- });
- }
+// jQuery 1.4+
+if ( $.cleanData ) {
+ var _cleanData = $.cleanData;
+ $.cleanData = function( elems ) {
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ $( elem ).triggerHandler( "remove" );
}
- return _remove.call( $(this), selector, keepData );
- });
-};
+ _cleanData( elems );
+ };
+} else {
+ var _remove = $.fn.remove;
+ $.fn.remove = function( selector, keepData ) {
+ return this.each(function() {
+ if ( !keepData ) {
+ if ( !selector || $.filter( selector, [ this ] ).length ) {
+ $( "*", this ).add( [ this ] ).each(function() {
+ $( this ).triggerHandler( "remove" );
+ });
+ }
+ }
+ return _remove.call( $(this), selector, keepData );
+ });
+ };
+}
$.widget = function( name, base, prototype ) {
var namespace = name.split( "." )[ 0 ],