Skip to content

Commit 27d1023

Browse files
tjvantollscottgonzalez
authored andcommitted
Draggable: Don't run stop methods for elements that have been removed. Fixed #8269 - Removing draggable element on drop : a(this).data("draggable") is undefined.
1 parent 4ab7d53 commit 27d1023

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ui/jquery.ui.draggable.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, {
207207
this.dropped = false;
208208
}
209209

210-
//if the original element is removed, don't bother to continue
211-
if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original")
210+
//if the original element is no longer in the DOM don't bother to continue (see #8269)
211+
var element = this.element[0], elementInDom = false;
212+
while ( element && (element = element.parentNode) ) {
213+
if (element == document ) {
214+
elementInDom = true;
215+
}
216+
}
217+
if ( !elementInDom && this.options.helper === "original" )
212218
return false;
213219

214220
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {

0 commit comments

Comments
 (0)