From d32183edc42ea2b8a4a6081fce18a79b8e2f0801 Mon Sep 17 00:00:00 2001 From: Dave Stein Date: Sun, 24 Feb 2013 18:47:24 -0500 Subject: [PATCH] Draggable: Fixed `backCompat` for `appendTo` when no helper exists --- ui/jquery.ui.draggable.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 64831b5b7..904cc51dc 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -85,11 +85,13 @@ $.widget( "ui.draggable", $.ui.interaction, { // Reset this.dragDimensions = null; - + // The actual dragging element, should always be a jQuery object this.dragEl = ( this.options.helper === true || typeof this.options.helper === "function" ) ? this._createHelper( pointerPosition ) : this.element; + + // _createHelper() ensures that helpers are in the correct position // in the DOM, but we need to handle appendTo when there is no helper @@ -564,11 +566,17 @@ if ( $.uiBackCompat !== false ) { // appendTo 'parent' value $.widget( "ui.draggable", $.ui.draggable, { + // Helper passed in since _createHelper calls this before dragEl is set _appendToEl: function() { var el = this.options.appendTo; - - if ( el === "parent" || el === null ) { + + // This should only happen via _createHelper + if ( el === null ) { + return this.element.parent(); + } + + if ( el === "parent" ) { el = this.dragEl.parent(); }