jqueryjquery-uijstreejstree-searchjstree-dnd

jstree expands for very short time and then collapses the tree on page refresh


I am using jstree in my project. when my page gets loaded, the entire tree expands for very short time and then collapses back to its original position. can someone please tell me how can i stop the tree from expanding on page load?


Solution

  • This can be solved by hiding the tree initially:

    <div id="myTreeDiv" style="display:none">
        <ul>
            ...
        </ul>
    </div>
    

    Then initialize & show it in one go with code similar to this:

    $("#myTreeDiv")
        .jstree({
            // set tree parameters here ...
        })
        .show();