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.

(cherry picked from commit 27d1023553)

Conflicts:

	ui/jquery.ui.draggable.js
This commit is contained in:
Scott González 2012-04-30 12:41:20 -04:00
parent 1ffafe65b0
commit f0c3cf6f1a

View File

@ -208,8 +208,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.dropped = false; this.dropped = false;
} }
//if the original element is removed, don't bother to continue if helper is set to "original" //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))) {