如何删除jstree中所选节点的子节点? [英] How to remove child nodes of selected node in jstree?

查看:223
本文介绍了如何删除jstree中所选节点的子节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在删除所选节点的子节点时遇到困难。

I am facing difficulty in deleting child nodes of a selected node.

$(function () {
$("#tree").jstree({ 
    "json_data" : {
        "data" : [
            { 
                data : "/", 
                attr : { "id" : "root"},
                state : "closed",
                "children" : [ { "data" : "child1",
                                "attr" : { "id" : "child1.id" },
                                "children" : [ ] }
                             ]
            },
        ]
    },
    "plugins" : [ "themes", "json_data", "crrm", "ui" ]
})

我使用$(#tree)。jstree(删除,data.rslt.obj);删除节点本身下面的子节点,但它也删除所选节点。如何删除所选节点的正常子节点而不删除所选节点?

I am using $("#tree").jstree("remove", data.rslt.obj); to remove the child nodes below the node itself but it also deletes the node selected. How can I delete the just child nodes of a selected node and not the selected node ?

推荐答案

正如@Redtopia正确指出的那样,jsTree没有最干净的API。

As @Redtopia correctly pointed out, jsTree does not have the cleanest API.

不幸的是,我认为解决方案必须是:

Unfortunately, I believe that the solution will have to be something like:

$("#tree").jstree("remove",data.rslt.obj.find('li'));

这篇关于如何删除jstree中所选节点的子节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆