views:

1004

answers:

1

I need to store which node currently has focus in a yui TreeView component. I thought that there would be a method to find which node has focus at any one time but can't seem to find it.

Does anyone know if such a method exists or otherwise suggest a way to do this?

thanks in advance,

+2  A: 

The next (2.7) version of TreeView will have a TreeView.currentFocus property which will point to the Node with the focus.

With 2.6, one alternative is to use Dom getElementsByClassName and search in the HTML for the tree for any element with className "ygtvfocus" then use TreeView method getNodeByElement which should tell you which Node it was.

There will be at least two elements returned with the focus className, one the toggle icon, the other the label. Any of them will do, just remember it is an array you have there.

Thanks very much, that sounds like a good strategy to follow. If only I had version 2.7 now! :p
Scottm
Damn...we are using an older version of the treeview class. I'll need to try and find another way.
Scottm