diff options
author | TJ VanToll <tj.vantoll@gmail.com> | 2012-04-30 12:39:06 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-04-30 12:39:06 -0400 |
commit | 27d10235539e0f5baad6ee7e8d3d91cab65e2cfd (patch) | |
tree | be7693ad39b5112847a674cafc8681acb2a32341 | |
parent | 4ab7d53b1cfb4e37e3c098ceddc33597b851a88f (diff) | |
download | jquery-ui-27d10235539e0f5baad6ee7e8d3d91cab65e2cfd.tar.gz jquery-ui-27d10235539e0f5baad6ee7e8d3d91cab65e2cfd.zip |
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.
-rw-r--r-- | ui/jquery.ui.draggable.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 25b256710..84077ed29 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, { this.dropped = false; } - //if the original element is removed, don't bother to continue - if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original") + //if the original element is no longer in the DOM don't bother to continue (see #8269) + 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; 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))) { |