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);