jannbmsy / dynatree

Automatically exported from code.google.com/p/dynatree
0 stars 0 forks source link

tree.getNodeByKey() returns node from wrong tree (when there are multiple trees with same keys) #442

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I have two separate trees on a page (e.g. tree1, tree2), each with a visible 
root node (a node below dynatree's hidden root) whose key is "/"  (FYI, my keys 
are pathnames, although that doesn't matter.)
2. $("#tree2").dynatree("getTree").getNodeByKey("/") returns the root node from 
tree1.  

It seems to me (without looking at your code) that your keys are indexed 
globally, rather than scoped per tree instance? If so, that's makes the keys 
unreliable for multiple trees unless we guarantee unique keys across all trees.

Dynatree version 1.2.4, revision 644, 2013-02-12 21:39:36
jQuery 1.9.1
Mac OS X, Safari.  (but doesn't matter?)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Original issue reported on code.google.com by augursys...@gmail.com on 15 Jul 2013 at 4:23

GoogleCodeExporter commented 8 years ago
The element id is generated from a prefix string + the node key. 
getNodeByKey() tries to find the Node by these ids first, before traversing the 
tree.
You can change the prefix with the 'keyIdPrefix' option (or similar) to make it 
unique

Original comment by moo...@wwwendt.de on 20 Jul 2013 at 3:51

GoogleCodeExporter commented 8 years ago

Original comment by moo...@wwwendt.de on 8 Sep 2013 at 6:48

GoogleCodeExporter commented 8 years ago
Issue 483 has been merged into this issue.

Original comment by moo...@wwwendt.de on 16 Apr 2014 at 8:39