Skip to content

Commit c0d0283

Browse files
Martin Hochscottgonzalez
Martin Hoch
authored andcommitted
Sortable: Fixed container change detection. Fixes #5159 - Remove and receive events on nested sortables.
(cherry picked from commit b9ef00f) Conflicts: ui/jquery.ui.sortable.js
1 parent a4ae382 commit c0d0283

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ui/jquery.ui.sortable.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,15 +1012,16 @@ $.widget("ui.sortable", $.ui.mouse, {
10121012

10131013
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
10141014
if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
1015-
if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
1016-
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1017-
for (var i = this.containers.length - 1; i >= 0; i--){
1018-
if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
1019-
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1020-
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1021-
}
1022-
};
1023-
};
1015+
1016+
// Check if the items Container has Changed and trigger appropriate
1017+
// events.
1018+
if (this !== this.currentContainer) {
1019+
if(!noPropagation) {
1020+
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1021+
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1022+
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1023+
}
1024+
}
10241025

10251026
//Post events to containers
10261027
for (var i = this.containers.length - 1; i >= 0; i--){

0 commit comments

Comments
 (0)