How do I open all nodes in jquery Jstree?

前端 未结 9 1757
感情败类
感情败类 2021-02-05 00:07

I am using the following code:

$("#treeview").jstree();
$("#treeview").jstree(\'open_all\');

With the following html:

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 00:55

    You can also apply animation to the opening and closing like so:

    $(document)
        .on("click", "#open-all-folders", function () {
            // param1 set to null to open/close all nodes
            // param2 is the duration in milliseconds
            $("#tree-ref").jstree().open_all(null, 200);
        })
        .on("click", "#close-all-folders", function () {
            $("#tree-ref").jstree().close_all(null, 200);
        });
    

    (or similarly apply to .on('ready.jstree', function() { // code here } );

提交回复
热议问题