Adding a hint to jstree is very simple. Before I write down the steps, let me explain what I will do
Prerequisites: You must use the jquery library and other dependencies. So in your head the tag should look something like this.
<head> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <script> $(function() { $( document ).tooltip(); }); </script> <style> label { display: inline-block; width: 5em; } </style> </head>
The above code will get the jquery library and the necessary css. He will also create the necessary style for the tool tip.
So now for the steps you need to take in Jstree. note that I am writing this answer for the latest version of jstree 3.0.2
We need to catch 'hover_node.jstree'
.on('hover_node.jstree',function(e,data){ $("#"+data.node.id).prop('title', "add your custom title here"); })
That's all you have to do, and jquery will take care of the rest to show a tooltip
The logic behind this is that jquery automatically checks to see if there is a tittle attribute associated with any node (i.e. element), and then displays a hint if there is any header. So, all we do is simply add the name to the node dynamically. This gives you the flexibility to add custom hints for each node depending on your data for each node, as well as hard code if it is fixed.
For more customization and styling, you can refer to the JQuery Tooltip
source share