diff --git a/README.md b/README.md index b86e091..e563f01 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ You can change the follow options: * `maxDepth` number of levels an item can be nested (default `5`) * `group` group ID to allow dragging between lists (default `0`) +* Class your itemNodeName with `clone` to clone the node on move (does not delete from original list) These advanced config options are also available: @@ -87,6 +88,10 @@ These advanced config options are also available: ## Change Log +### 24th September 2018 + +* Add cloneable nodes + ### 15th October 2012 * Merge for Zepto.js support diff --git a/jquery.nestable.js b/jquery.nestable.js index 7323fb4..229fd42 100644 --- a/jquery.nestable.js +++ b/jquery.nestable.js @@ -265,8 +265,19 @@ this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass); this.dragEl.css('width', dragItem.width()); - dragItem.after(this.placeEl); - dragItem[0].parentNode.removeChild(dragItem[0]); + if($(dragItem[0]).hasClass("clone")) + { + var cloneNode = dragItem[0].cloneNode(true); + dragItem[0].parentNode.replaceChild(cloneNode, dragItem[0]); + $(dragItem[0]).removeClass("clone"); + dragItem.after(this.placeEl); + } + else + { + dragItem.after(this.placeEl); + dragItem[0].parentNode.removeChild(dragItem[0]); + } + dragItem.appendTo(this.dragEl); $(document.body).append(this.dragEl);