JsTree

 $("-sharpjurisdictionBox").on("changed.jstree", function (e, data) {  
       console.log(data.selected);
       console.log(data)
 }); 

data:[
  {
                    "id":"00",
                    "text": "",
                    "state": {
                        "selected": false
                    },
                },
                {
                    "id":"01",
                    "text":"",
                     "children": [{
                         "id":"0101",
                        "text": "",
                        "state": {
                           "selected": false
                         }
                        }, {
                            "id":"0102",
                            "text": "",
                            "state": {
                              "selected": false
                             }
                        },
                    ]
                }
]

now the requirement is to know the id of the selected node. How to traverse the original data to make the selected node"s "selected": the selected attribute of false is saved to the background as true,

Feb.27,2021

the requirement now is to know how to traverse the id of the selected node to make the selected node "selected": the selected attribute of false is true
. What else to do with combing
var data = [
  {
    id: '00',
    text: '',
    state: {
      selected: false,
    },
  },
  {
    id: '01',
    text: '',
    children: [
      {
        id: '0101',
        text: '',
        state: {
          selected: false,
        },
      },
      {
        id: '0102',
        text: '',
        state: {
          selected: false,
        },
      },
    ],
  },
]

var selected = ['00', '0101']

var iterative = (data, callback) => {
  if (Array.isArray(data)) {
    data.forEach(item => {
      if (item.children && item.children.length) {
        iterative(item.children, callback)
      }
      callback(item)
    })
    return
  }
  callback(data)
}

iterative(data, item => {
  if (selected.includes(item.id)) {
    item.state.selected = !item.state.selected
  }
})
console.log(data)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b14d-2b5ca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b14d-2b5ca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?