Skip to content

Commit

Permalink
Fixed replace method (added collapse/expand buttons when item has c…
Browse files Browse the repository at this point in the history
…hildren), fixes #69
  • Loading branch information
pjona committed Jul 10, 2017
1 parent df896e3 commit c2def01
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions jquery.nestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
var html = this._buildItem(item, this.options);

this._getItemById(item.id)
.html(html);
.replaceWith(html);
},

remove: function (itemId)
Expand Down Expand Up @@ -360,8 +360,11 @@

var content = options.contentCallback(item);
var children = this._buildList(item.children, options);
var html = $(options.itemRenderer(item_attrs, content, children, options, item));

return options.itemRenderer(item_attrs, content, children, options, item);
this.setParent(html);

return html[0].outerHTML;
},

serialize: function() {
Expand Down Expand Up @@ -433,7 +436,7 @@
serialise: function() {
return this.serialize();
},

toHierarchy: function(options) {

var o = $.extend({}, this.options, options),
Expand Down Expand Up @@ -710,13 +713,13 @@
};
//Get indexArray of item at drag start.
var srcIndex = this.dragEl.data('indexOfItem');

var el = this.dragEl.children(this.options.itemNodeName).first();

el[0].parentNode.removeChild(el[0]);

this.dragEl.remove(); //Remove dragEl, cause it can affect on indexing in html collection.

//Before drag stop callback
var continueExecution = this.options.beforeDragStop.call(this, this.el, el, this.placeEl.parent());
if (typeof continueExecution !== 'undefined' && continueExecution === false) {
Expand All @@ -729,7 +732,7 @@
this.reset();
return;
}

this.placeEl.replaceWith(el);

if(this.hasNewRoot) {
Expand Down

0 comments on commit c2def01

Please sign in to comment.