mbraak / jqTree

Tree widget for jQuery
https://mbraak.github.io/jqTree/
Apache License 2.0
1.02k stars 177 forks source link

using jqtree for navigation #21

Closed patecs closed 12 years ago

patecs commented 12 years ago

I'm having some trouble implementing the saveState option. I think it's because of the way I'm using this tree for navigation. I've included the cookie and have saveState = true. Each node is a link to a page for navigation. EX:

            label: '<a href="link-1.html">Menu 1.7.2</a>',
                children: [
                    {label: '<a href="">Sigma Phi Epsilon</a>'},
                    {
                        label: '<a href="link-2.html">Menu 2 1.7.2</a>',
                        children: [
                            {label: '<a href="link-3.html">Menu 3 1.7.2</a>'},

Where each link contains the same tree.

Is it possible to saveState using jqTree this way? Is there a parameter I can add on the end of each link?

mbraak commented 12 years ago

For saveState to work, you should give each node in the tree data an id field. I will add this to the documentation.

{
  label: '<a href="link-1.html">Menu 1.7.2</a>',
  id: 1,
  children: [
    label: ''<a href="">Sigma Phi Epsilon</a>',
    id: 2
  ]
}

I use 1 and 2 for the ids in this example, but you can of course use whatever you like.

patecs commented 12 years ago

works perfectly, thanks so much.