Search code examples
javascriptjqueryjstreejstree-search

jsTree search textbox does not appear


I am using jsTree (http://www.jstree.com/plugins/) with below plugins

 "plugins" : [ "dnd" , "contextmenu" ,"ui" , "types" ,  "search" ,"sort" ]

All plugins are working fine except search.There is no search textbox added above tree to search node.Is there any other dependency to use search in jsTree. Please help.


Solution

  • Just add in a search box above your tree:

    <input id="plugins4_q" type="text" placeholder="search">
    

    Note that you'll also need to monitor the search box for text entry and pass the data to the jstree search function. Example javascript:

    var to = false;
      $('#plugins4_q').keyup(function () {
        if(to) { clearTimeout(to); }
        to = setTimeout(function () {
          var v = $('#plugins4_q').val();
          $('#plugins4').jstree('search', v);
        }, 250);
     });