Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Add Cloneable Nodes #219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand Down
15 changes: 13 additions & 2 deletions jquery.nestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down