yaugenka
yaugenka

Reputation: 2861

How to make Fancytree send select event to child nodes when a parent is selected?

I created a hierarchical tree with Fancytree jquery plugin v2.12.0

-node 1
--node 1.1
--node 1.2
-node 2

It has checkboxes and multi-hier selecton mode enabled.

I also set up a function for select event:

select: function(e, data){
  //some logic
}

I expect this function to be applied to all nodes which get checked but the problem is when you select (check) a parent node its children get selected (checked) as well but the select event is triggered for the parent node only.

I can definetly loop through child nodes myself but is it possible make the control trigger select event on child notes when a parent is selected?

Upvotes: 0

Views: 1679

Answers (1)

superdimon
superdimon

Reputation: 66

It seems the "select" event being called only for node that was selected. I suggest you to visit child nodes.

select: function(e, data){
  if(data.node.hasChildren()){
    data.node.visit(function(child){
      //your logic
    });
  }
}

Upvotes: 1

Related Questions