Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I am creating a tree for use with jstree (this is a test set of data, the actual program will create the data on the fly). However, this data seems to be showing as recursive... Why would this be?

 

[   {
     "data":"Year 5",
     "attr":{
        "id":"1",
        "rel":"year"
     },
     "children":[
        {
           "data":"5AM",
           "state":"closed",
           "children":[
              {
                 "data":"Pupil",
                 "state":"closed",
                 "attr":{
                    "id":"2",
                    "rel":"pupil"
                 }
              }
           ],
           "attr":{
              "id":"2",
              "rel":"class"
           }
        },
        {
           "data":"5BA",
           "state":"closed",
           "attr":{
              "id":"3",
              "rel":"class"
           }
        },
        {
           "data":"5CZ",
           "state":"closed",
           "attr":{
              "id":"4",
              "rel":"class"
           }
        }
     ]
  }
]

Posted

Well, this isn't the 'right' fix but it works. Setting the "state" of any childless node to "leaf" stops the recursion.

 

Makes it annoying for generating the JSON though!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...