MaatDeamon
MaatDeamon

Reputation: 9761

Javascript FancyTree: is it possible to distinguish between the selection of a node and the action of expanding it.

I would like to achieve the following behavior with my tree.

When someone select the corner icon that signal that the node is expandable, i would like the node to expand and only expand (no selection). Meanwhile, when someone select the node (i.e. one click the text of the node), i want that a specific handler that i made be executed and no expansion of the node.

This is because in my application, when a user select/one click an element of the tree, the element is added, to another list within the html. Let say a list of selected item.

So in other words:

In short, is it possible to distinguish between the selection of a node and the action of expanding it.

Upvotes: 1

Views: 401

Answers (1)

sfinks_29
sfinks_29

Reputation: 918

Setting clickFolderMode to 1 will get you the behavior you're after:

When someone select the corner icon that signal that the node is expandable, i would like the node to expand and only expand (no selection). Meanwhile, when someone select the node (i.e. one click the text of the node), i want that a specific handler that i made be executed and no expansion of the node.

$("#tree").fancytree({
    clickFolderMode: 1 // 1:activate, 2:expand, 3:activate and expand
});

You should then be able to use the onSelect and onExpand event handlers to do what you need to depending on which action the user performed.

Upvotes: 1

Related Questions