Uncaught TypeError: m[dat[i].parent.toString(...)].children.push is not a function

1,077 views
Skip to first unread message

Todd Mc Brearty

unread,
Jul 1, 2015, 1:52:58 PM7/1/15
to jst...@googlegroups.com


im receiving this error
Uncaught TypeError: m[dat[i].parent.toString(...)].children.push is not a function

my code is this.

$("#encodable-tree").jstree({
    "core": {
      "data": [
        {
          id: "108",
          text: "108",
          parent: "#",
          children: true
        },
        {
          id: "108/include",
          text: "include",
          parent: "108",
          children: true
        }
      ]
    },
    "progressive_unload": false,
    "progressive_render": true,
    "contextmenu": {"select_node": "true"}
  });

The line of JS that is getting the error is a generated file i guess? it's blob:http://...........
the area of the error occurs in this block
// 2) populate children (foreach)
for(i = 0, j = dat.length; i < j; i++) {
m[dat[i].parent.toString()].children.push(dat[i].id.toString()); //this is the offending line
// populate parent.children_d
p.children_d.push(dat[i].id.toString());
}

if i remove the second object the 108 directory shows but when i add it in it breaks with that error. i've been staring at it for almost 2 days and im sure it's something stupid.

Thanks 

Ivan Bozhanov

unread,
Jul 2, 2015, 8:23:17 AM7/2/15
to jst...@googlegroups.com, todd.mc...@gmail.com
Hi,

Keep in mind you are using a lot of v.1 options mixed with v.3 options. Since you are using v.3 those will have no effect.
Here is your code with those options cleaned up:
http://jsfiddle.net/DGAF4/554/

The key to get this working is the children property which you have set to true. True means that children will be loaded at a later time, but at the same time - you are passing in the children (for the 108 node).
Simply remove this property - in the flat format which you are using the children property should only be used if you want to load the children at a later time.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages