jqTree icon indicating copy to clipboard operation
jqTree copied to clipboard

Is there any event triggering when tree fully loaded?

Open sergeydor opened this issue 11 years ago • 10 comments

I have read documentation a few times and as I understood there is no event which can be triggered when the tree is fully loaded. It would be nice to have such event.

sergeydor avatar May 07 '15 10:05 sergeydor

The tree.init is called when the data is loaded.

Or do you mean something else with fully loaded?

mbraak avatar May 07 '15 11:05 mbraak

Yeah. Sorry, I just not understood from name that this event is triggered when the tree is loaded. But there is one issue. I would like to trigger similar event when the tree is rebuilt after drag-and-drop any node. Is it possible?

sergeydor avatar May 07 '15 11:05 sergeydor

The tree.refresh event is triggered when the tree is rendered. So, also after drag-and-drop. I see that this event is not documented yet.

The tree.move is called before the move.

Does this help?

mbraak avatar May 07 '15 11:05 mbraak

Yes! Thank you! You are right there is no description of event tree.refresh in documentation.

sergeydor avatar May 07 '15 12:05 sergeydor

Could you please send me a sample how we can use the tree.refresh?

thank you in advance.

husseinkhatib avatar May 27 '15 07:05 husseinkhatib

You can use tree.refresh like this:

$('#tree1').on('tree.refresh', function() {
  // This function is called after the tree rendered
});

I personally never use this event. Depending on your use case there are other options:

  • tree.init which is called after the tree data is loaded.
  • onCreateLi to customize the rendering of the tree.

mbraak avatar May 27 '15 07:05 mbraak

Why when i re draw the tree the function of the tree did not work?

husseinkhatib avatar May 27 '15 07:05 husseinkhatib

How exactly do you redraw the tree?

mbraak avatar May 27 '15 09:05 mbraak

$('#tree1').tree({ data: data, autoOpen: false, dragAndDrop: true, load_on_demand:true, cache: false, closedIcon: '<i class="fa fa-chevron-right " style="margin-left:3px" ></i>', openedIcon: '<i class="fa fa-chevron-down " style="margin-left:2px" ></i>' });

husseinkhatib avatar May 27 '15 09:05 husseinkhatib

And after that you connect the tree.refresh event?

In this case the tree.refresh will not be fired because the tree is rendered before you connect the event. I think it will be fired when you do drag-and-drop or when you load a node on demand.

mbraak avatar May 27 '15 10:05 mbraak