Open branch when clicking on a node?

后端 未结 3 454
抹茶落季
抹茶落季 2021-02-02 09:52

I\'m stuck with jsTree here. So far it works and i can browse and expand nodes with the [+] icon and open pages when clicking a node, BUT i still want it to expand all the immed

3条回答
  •  忘了有多久
    2021-02-02 10:27

    I use this (casoUso is the page linked, fInvocaCasoUso is a function to make the call).

      $("#demo1").bind("select_node.jstree", function (e, data)
                        {
                            if (data.rslt.obj.attr("casoUso")!=undefined)
                            {
                                fInvocaCasoUso(data.rslt.obj.attr("casoUso"));
                            }
                            else
                            {
                                $("#demo1").jstree("toggle_node",data.rslt.obj);
                            }
                        });
    

    If the node has a link, it opens, if not, the sub-tree is opened. Anyway, you should be able to combine both sides of "if" to open the branch and execute your link. Maybe executing:

           $("#demo1").jstree("toggle_node",data.rslt.obj);
           fInvocaCasoUso(data.rslt.obj.attr("casoUso"));
    

    Would do it...

提交回复
热议问题