BALKANGraph / FamilyTreeJS

Build family tree app with BALKAN FamilyTreeJS library. Family Tree also called a genealogy or a pedigree chart, is a chart representing family relationships in a conventional tree structure.
55 stars 16 forks source link

updating node returns error #16

Closed ezeagwulae closed 2 years ago

ezeagwulae commented 2 years ago

When updating a node with the updateNode method found here, I'm getting the following console error

familytree.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at FamilyTree.updateNode (familytree.js:1:28298)

This is what I'm doing

family.on('update', function (sender, oldnode, newnode) {
  // send updated info to backend
  .....

  // redraw family tree with updated object
  sender.updateNode(newnode)

}

I've tried following similar instructions here https://github.com/BALKANGraph/OrgChartJS/issues/382, but still hitting a dead end. Any guidance would be helpful. The error returns when using the updateNode to redraw the family tree

ZornitsaPesheva commented 2 years ago

Hi @ezeagwulae ,

This is the right way to use the event: https://code.balkan.app/update-family-tree-js/update-node-event-listener#JS But on Update the node is already updated. What do you need to do? If you use updateNode in update, it will call itself and will do a recursion.

ezeagwulae commented 2 years ago

Thanks for that. I was under the impression additional actions are needed after an update.

That said, what is the use for updateNode?

ZornitsaPesheva commented 2 years ago

updateNode is to update the node programmatically. Actually we are still using it only internally.