I'm using Fancytree for radio buttons. I'd like to be able to click on either the title or the associated radio button to select the node.
With basic Fancytree initialization,
$("#tree").fancytree({
checkbox: true, // turn on checkboxes
selectMode: 1 // allow only a single selection
});
clicking on the node title highlights the title, but doesn't tick the radio button. After that, ticking a radio button selects the node, but the highlight on the previously selected node remains. Try it here: https://jsfiddle.net/slothbear/db4gzh47
I've read the FAQ that Fancytree maintains separate states for active, selected, focused, and hovered. I've tried a lot of the events to keep the node selection and activation in sync, but haven't found the right combo yet.
Is there a way to simulate the behavior of labeled HTML radio buttons, where you can click on either the label or the radio button? Example: http://jsfiddle.net/Gu55B/1/
click
. I tried addingdata.node.setSelected(true)
to that event. That works ok when clicking on the label. When the radio button is clicked, it looks like the node is not selected. Actually the node gets selected, but then deselected – I think because mysetSelected
updated the value oflastSelectedNode
? Test here: jsfiddle.net/slothbear/rxtxfk9m - slothbear