aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAndrei Picus <office.nightcrawler@gmail.com>2013-10-29 15:48:51 +0200
committerMike Sherov <mike.sherov@gmail.com>2013-10-29 13:58:15 -0400
commitffab89e9bee97cf7cc74249b6e4ce9dd798013c9 (patch)
treea28c9160b5a78b53d84b31730141035d44b022c2 /ui
parenta3715a7c919d242e3ffcdddc2f1db61133d9f560 (diff)
downloadjquery-ui-ffab89e9bee97cf7cc74249b6e4ce9dd798013c9.tar.gz
jquery-ui-ffab89e9bee97cf7cc74249b6e4ce9dd798013c9.zip
Droppable: update ddmanager when scope changes through setOption. Fixed #9287 - droppable: Scope option cannot be changed after initialization.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.droppable.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js
index d21d1790a..0e4b65cc4 100644
--- a/ui/jquery.ui.droppable.js
+++ b/ui/jquery.ui.droppable.js
@@ -63,23 +63,31 @@ $.widget( "ui.droppable", {
}
};
- // Add the reference and positions to the manager
- $.ui.ddmanager.droppables[ o.scope ] = $.ui.ddmanager.droppables[ o.scope ] || [];
- $.ui.ddmanager.droppables[ o.scope ].push( this );
+ this._addToManager( o.scope );
o.addClasses && this.element.addClass( "ui-droppable" );
},
- _destroy: function() {
- var i = 0,
- drop = $.ui.ddmanager.droppables[ this.options.scope ];
+ _addToManager: function( scope ) {
+ // Add the reference and positions to the manager
+ $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
+ $.ui.ddmanager.droppables[ scope ].push( this );
+ },
+ _splice: function( drop ) {
+ var i = 0;
for ( ; i < drop.length; i++ ) {
if ( drop[ i ] === this ) {
drop.splice( i, 1 );
}
}
+ },
+
+ _destroy: function() {
+ var drop = $.ui.ddmanager.droppables[ this.options.scope ];
+
+ this._splice( drop );
this.element.removeClass( "ui-droppable ui-droppable-disabled" );
},
@@ -90,7 +98,13 @@ $.widget( "ui.droppable", {
this.accept = $.isFunction( value ) ? value : function( d ) {
return d.is( value );
};
+ } else if ( key === "scope" ) {
+ var drop = $.ui.ddmanager.droppables[ this.options.scope ];
+
+ this._splice( drop );
+ this._addToManager( value );
}
+
this._super( key, value );
},