Skip to content

Commit

Permalink
Draggable: Don't run stop methods for elements that have been removed…
Browse files Browse the repository at this point in the history
…. Fixed #8269 - Removing draggable element on drop : a(this).data("draggable") is undefined.
  • Loading branch information
tjvantoll authored and scottgonzalez committed Apr 30, 2012
1 parent 4ab7d53 commit 27d1023
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ui/jquery.ui.draggable.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.dropped = false; this.dropped = false;
} }


//if the original element is removed, don't bother to continue //if the original element is no longer in the DOM don't bother to continue (see #8269)
if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original") var element = this.element[0], elementInDom = false;
while ( element && (element = element.parentNode) ) {
if (element == document ) {
elementInDom = true;
}
}
if ( !elementInDom && this.options.helper === "original" )
return false; return false;


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))) { 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))) {
Expand Down

0 comments on commit 27d1023

Please sign in to comment.