diff options
author | Andrei Picus <office.nightcrawler@gmail.com> | 2013-10-29 15:48:51 +0200 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2013-10-29 13:58:15 -0400 |
commit | ffab89e9bee97cf7cc74249b6e4ce9dd798013c9 (patch) | |
tree | a28c9160b5a78b53d84b31730141035d44b022c2 /ui | |
parent | a3715a7c919d242e3ffcdddc2f1db61133d9f560 (diff) | |
download | jquery-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.js | 26 |
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 ); }, |