如何拒绝删除/重命名/移动jsTree中的根(或其他)节点? [英] how to deny delete/rename/move root(or other) node(s) in jsTree?

查看:260
本文介绍了如何拒绝删除/重命名/移动jsTree中的根(或其他)节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

[{
"data": "reference",
"attr": {
    "id": "0"
},
"state": "open",
"children": [
    [{
        "data": "one",
        "attr": {
            "id": "1"
        },
        "state": "closed"
    }, {
        "data": "two",
        "attr": {
            "id": "2"
        }
    }]
]
}, {
"data": "recycle bin",
"attr": {
    "id": "bin"
},
"state": "closed",
"children": []
}]

我需要拒绝删除/移动/重命名引用"&带有"dnd","crrm"和上下文菜单"插件的回收站"节点

i need to deny delete/move/rename "reference" & "recycle bin" nodes with "dnd", "crrm" and "context menu" plugins

推荐答案

使用 crrm插件您可以这样做:

"crrm": {
   "move": {
      "check_move": function(m) { return (m.o[0].id !== "0" && m.o[0].id !== "bin"); }
   }
}

总而言之,您需要返回TRUE以允许移动,否则返回FALSE.因此,请检查要移动的节点ID是否不是引用回收站之一.

In summary, you need to return TRUE for allowing the move, or FALSE otherwise. So you check that the node's ID being moved is not the reference one, or the recycle bin one.

请查看 jsTree文档,以完成其他任务,因为您需要的一切都在那里.别偷懒:-)

Please take a look at the jsTree documentation for accomplishing the other tasks, as everything you need is there. Don't be lazy :-)

这篇关于如何拒绝删除/重命名/移动jsTree中的根(或其他)节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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