If I click on my fancytree menu nodes they activate dialog boxes that appear next to the menu. These have cancel buttons that make the dialog close. However, when I click on the same menu item (node) again the same dialog box does not appear again (as I want it to), I think because Fancytree thinks it's the currently selected node so ignores it.
If I click on a different menu item instead, it works fine and the dialog box for that one appears. So how do I get Fancytree to fire the same activate:
function for the currently selected menu item when it's clicked again?
In my cancel button handler I tried using node.setSelected(false)
which should deselect the item, but still the dialog box does not re-appear when I click the same item again. I've confirmed that it's the correct (current) node that setSelected(false) is used on.
I'm just using a standard fancytree config, e.g. the following:
var currentMenuItemNode;
$("#tree").fancytree({
activate: function(event, data){
this.currentMenuItemNode = data.node;
}
});
cancelButtonHandler() {
// Close dialog box here
this.currentMenuItemNode.setSelected(false); // Deselect item
}
Any thoughts welcome!
The activate
event is not fired if a node is already active, so the click event might be what you're looking for:
$("#tree").fancytree({
[...]
click: function(event, data) {
var node = data.node,
// Only for click and dblclick events:
// 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon'
targetType = data.targetType;
// we could return false to prevent default handling, i.e. generating
// activate, expand, or select events
},
});