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.
我需要在yui TreeView组件中存储当前具有焦点的节点。我认为有一种方法可以找到哪个节点在任何时候都有焦点但似乎无法找到它。
Does anyone know if such a method exists or otherwise suggest a way to do this?
有谁知道这种方法是否存在或以其他方式建议这样做的方法?
thanks in advance,
提前致谢,
1 个解决方案
#1
The next (2.7) version of TreeView will have a TreeView.currentFocus property which will point to the Node with the focus.
TreeView的下一个(2.7)版本将具有TreeView.currentFocus属性,该属性将指向具有焦点的Node。
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.
使用2.6,一种替代方法是使用Dom getElementsByClassName并在HTML中搜索具有className“ygtvfocus”的任何元素的树,然后使用TreeView方法getNodeByElement,它应该告诉您它是哪个节点。
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.
将返回至少两个带有焦点className的元素,一个是切换图标,另一个是标签。他们中的任何一个都会这样做,只记得它是你在那里的阵列。
#1
The next (2.7) version of TreeView will have a TreeView.currentFocus property which will point to the Node with the focus.
TreeView的下一个(2.7)版本将具有TreeView.currentFocus属性,该属性将指向具有焦点的Node。
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.
使用2.6,一种替代方法是使用Dom getElementsByClassName并在HTML中搜索具有className“ygtvfocus”的任何元素的树,然后使用TreeView方法getNodeByElement,它应该告诉您它是哪个节点。
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.
将返回至少两个带有焦点className的元素,一个是切换图标,另一个是标签。他们中的任何一个都会这样做,只记得它是你在那里的阵列。