From ae4a854e188165239ebd961df53a557431f0dd9c Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Mon, 11 Feb 2013 15:46:58 -0500 Subject: [PATCH] Bug 180 --- cms/static/js/views/overview.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cms/static/js/views/overview.js b/cms/static/js/views/overview.js index 8cbae177a8..d064f24006 100644 --- a/cms/static/js/views/overview.js +++ b/cms/static/js/views/overview.js @@ -202,13 +202,17 @@ function _handleReorder(event, ui, parentIdField, childrenSelector) { children = _.without(children, ui.draggable.data('id')); } // add to this parent (figure out where) - for (var i = 0; i < _els.length; i++) { - if (!ui.draggable.is(_els[i]) && ui.offset.top < $(_els[i]).offset().top) { + for (var i = 0, bump = 0; i < _els.length; i++) { + if (ui.draggable.is(_els[i])) { + bump = -1; // bump indicates that the draggable was passed in the dom but not children's list b/c + // it's not in that list + } + else if (ui.offset.top < $(_els[i]).offset().top) { // insert at i in children and _els ui.draggable.insertBefore($(_els[i])); // TODO figure out correct way to have it remove the style: top:n; setting (and similar line below) ui.draggable.attr("style", "position:relative;"); - children.splice(i, 0, ui.draggable.data('id')); + children.splice(i + bump, 0, ui.draggable.data('id')); break; } }