Skip to content

Commit 5c8c967

Browse files
author
Matt Parnell
committed
Merge pull request mjsarfatti#87 from noraheuer/master
_clearEmpty improvements, toArray data collection
2 parents 2ab5fc1 + 938e5ec commit 5c8c967

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

jquery.mjs.nestedSortable.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -785,15 +785,15 @@
785785
}
786786

787787
if (id) {
788-
var name = $(item).data("name");
789-
ret.push({
790-
"id": id[2],
791-
"parent_id": pid,
792-
"depth": depth,
793-
"left": _left,
794-
"right": right,
795-
"name":name
796-
});
788+
var data = $(item).children('div').data();
789+
var itemObj = $.extend( data, {
790+
"id":id[2],
791+
"parent_id":pid,
792+
"depth":depth,
793+
"left":_left,
794+
"right":right
795+
} );
796+
ret.push( itemObj );
797797
}
798798

799799
_left = right + 1;
@@ -813,7 +813,7 @@
813813

814814
var o = this.options,
815815
childrenList = $(item).children(o.listType),
816-
hasChildren = childrenList.is(':not(:empty)');
816+
hasChildren = childrenList.has('li').length;
817817

818818
var doNotClear =
819819
o.doNotClear ||
@@ -822,13 +822,10 @@
822822

823823
if (o.isTree) {
824824
replaceClass(item, o.branchClass, o.leafClass, doNotClear);
825-
826-
if (doNotClear && hasChildren) {
827-
replaceClass(item, o.collapsedClass, o.expandedClass);
828-
}
829825
}
830826

831827
if (!doNotClear) {
828+
childrenList.parent().removeClass(o.expandedClass);
832829
childrenList.remove();
833830
}
834831
},

0 commit comments

Comments
 (0)