Skip to content

Commit 8ee0357

Browse files
committed
fixed bug menu: array to tree when the children are pushed into the map first
1 parent 2888a08 commit 8ee0357

File tree

1 file changed

+5
-2
lines changed
  • src/Modules/SimplCommerce.Module.Cms/wwwroot/admin/menu

1 file changed

+5
-2
lines changed

src/Modules/SimplCommerce.Module.Cms/wwwroot/admin/menu/menu-form.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,13 @@
8787

8888
function arrayToTree(arr) {
8989
var map = {}, node, roots = [];
90+
// use map to look-up the parents
91+
for (var i = 0; i < arr.length; i += 1) {
92+
map[arr[i].id] = i;
93+
}
94+
9095
for (var i = 0; i < arr.length; i += 1) {
9196
node = arr[i];
92-
node.children = [];
93-
map[node.id] = i; // use map to look-up the parents
9497
if (node.parentId) {
9598
arr[map[node.parentId]].children.push(node);
9699
} else {

0 commit comments

Comments
 (0)