Search code examples
javascriptjstree

The icon change after expand in Jstree


I have the icon from font awesome.

<li data-jstree='{"icon":"fa fa-envelope-o"}'>
    <span id="id">Description</span>
    <ul>
        <li data-jstree='{"disabled":true}'>
        <span id="id">Documents</span>
       </li> 
    </ul>
</li>

enter image description here

and when I open the node, the icon change to it's original state.

enter image description here

I have the problem with only 'fa fa-envelope-o', if I test with anoter like 'fa fa-envelope-open-o' it's work.

Thank you.


Solution

  • I found this solution, maybe there is a better way.

    $('#TreeId').on("close_node.jstree", function (e,data) {    
        setTimeout(function(){
        $("#" + data.node.id).find('i').eq(1).removeClass('fa-minus-circle fa-plus-circle');        
        }, 1);
    });