From 67cd3a63adff23224e1ef33a11640e5e4961eb66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Heged=C3=BCs?= Date: Mon, 26 Jun 2017 07:12:38 +0200 Subject: [PATCH] [Add] get moved item method. You can get the moved element. --- README.md | 4 ++++ jquery.nestable.js | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b86e091..430254f 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ The serialised JSON for the example above would be: [{"id":1},{"id":2},{"id":3,"children":[{"id":4},{"id":5}]}] +You can get the moved element. + + $('.dd').nestable('getMovedItem'); + ### Configuration You can change the follow options: diff --git a/jquery.nestable.js b/jquery.nestable.js index 7323fb4..22a5171 100644 --- a/jquery.nestable.js +++ b/jquery.nestable.js @@ -55,6 +55,8 @@ Plugin.prototype = { + movedItem: null, + init: function() { var list = this; @@ -166,6 +168,10 @@ return this.serialize(); }, + getMovedItem: function () { + return this.movedItem; + }, + reset: function() { this.mouse = { @@ -287,7 +293,8 @@ dragStop: function(e) { - var el = this.dragEl.children(this.options.itemNodeName).first(); + var el = this.movedItem = this.dragEl.children(this.options.itemNodeName).first(); + el[0].parentNode.removeChild(el[0]); this.placeEl.replaceWith(el);