Posted By

vtoman on 11/10/11


Tagged

jsTree


Versions (?)

Opening / closing jstree node


 / Published in: jQuery
 

Clicking on node makes it toggle between opened and closed. Nodes needs to have id attribute for this to work.

  1. .bind("select_node.jstree", function (event, data) {
  2. var id = data.rslt.obj.attr("id");
  3. if (id != undefined) {
  4. if ($("li[id=" + id + "]").hasClass("jstree-open"))
  5. $("#treeViewContainer").jstree("close_node", "#" + id);
  6. else
  7. $("#treeViewContainer").jstree("open_node", "#" + id);
  8. }
  9. }
  10.  
  11. <div id="treeViewContainer">
  12. <ul>
  13.  
  14. </ul>
  15. </div>

Report this snippet  

You need to login to post a comment.