jsTree copy_modifier : false -- 不阻止节点复制!

发布于 2024-11-14 10:26:49 字数 3652 浏览 4 评论 0原文

这是我的代码,它应该在使用 ctrl 键时防止节点复制,但它仍然允许复制并且不会阻止它。

我按照文档使用 "copy_modifier" : false - 知道为什么它不起作用吗?

我正在使用几天前通过网站上的大下载按钮下载的稳定版本“jsTree 1.0-rc3”

$(function () {

    $("#jsTree")
        .jstree({
            "plugins" : ["themes","html_data","ui","crrm","hotkeys","types","dnd","contextmenu"], contextmenu: {items: customMenu}
            //"core" : { "initially_open" : [ "node_root" ] }
        ,"types" : {
            "valid_children" : [ "group","unknowngroup" ],
            "types" : {
                "group" : {
                    "valid_children" : ["event"],
                    "start_drag" : false,
                    "move_node" : false,
                    "delete_node" : false,
                    "remove" : false,
                    "icon" : {
                        "image" : "layout/img/folder.png"
                    },
                },
                "unknowngroup" : {
                    "valid_children" : ["event"],
                    "start_drag" : false,
                    "move_node" : false,
                    "delete_node" : false,
                    "remove" : false,
                    "icon" : {
                        "image" : "http://www.veryicon.com/icon/16/System/Pleasant/Recycle%20Bin%20e.png"
                    },
                },
                "event" : {
                    "valid_children" : "none",
                    "icon" : {
                        "image" : "http://ouccc.objectis.net/events/aggregator/previous/event_icon.gif"
                    },
                    "start_drag" : true,
                    "move_node" : true,
                    "delete_node" : false,
                    "remove" : false
                }
            },
            "dnd" : {
                "copy_modifier" : false,
                "drag_check" : function (data) {
                    return { 
                        after : true , 
                        before : true , 
                        inside : true 
                    };
                }
            }
        }
        }).bind("rename.jstree", function (e, data) {
            if(prefix!="")
            {
                commitGroupRename(data.rslt.obj.attr("id").substring(11),data.rslt.new_name);
                var text= prefix + data.rslt.new_name;
                $("#jsTree").jstree('rename_node', data.rslt.obj, text );
                prefix="";
            }
        }).bind("loaded.jstree", function (event, data) {
                //$("#jsTree").jstree("open_all");
        }).bind("dblclick.jstree", function (event) {
            var node = $(event.target).closest("li");
            //var data = node.data("jstree");
            if ($(node).attr('rel')=="group" && prefix =='')
            {
                var text = $("#jsTree").jstree('get_text',node);
                prefix = text.substring(0,5);
                text = text.substring(5);
                $("#jsTree").jstree("rename_node", node , text );
                $("#jsTree").jstree("rename",node);
            }
        }).bind("select_node.jstree", function (node, ref_node) {
            var theRealNode = $.jstree._focused().get_selected();
            if (theRealNode.attr('rel')=="group")
            {
                $('#btnRenameSelected').attr("disabled", false);
                $('#btnRenameSelected').removeClass("ui-state-disabled");
            }
            else
            {
                $('#btnRenameSelected').attr("disabled", true);
                $('#btnRenameSelected').addClass("ui-state-disabled");
            }
           });
});

Here is my code, its supposed to prevent node copy when using ctrl key, but it still allows copy and doesn't prevent it.

I use "copy_modifier" : false as per the documentation - any idea why it doesn't work?

I am using the stable version "jsTree 1.0-rc3" downloaded via the big download button on the website only a few days ago.

$(function () {

    $("#jsTree")
        .jstree({
            "plugins" : ["themes","html_data","ui","crrm","hotkeys","types","dnd","contextmenu"], contextmenu: {items: customMenu}
            //"core" : { "initially_open" : [ "node_root" ] }
        ,"types" : {
            "valid_children" : [ "group","unknowngroup" ],
            "types" : {
                "group" : {
                    "valid_children" : ["event"],
                    "start_drag" : false,
                    "move_node" : false,
                    "delete_node" : false,
                    "remove" : false,
                    "icon" : {
                        "image" : "layout/img/folder.png"
                    },
                },
                "unknowngroup" : {
                    "valid_children" : ["event"],
                    "start_drag" : false,
                    "move_node" : false,
                    "delete_node" : false,
                    "remove" : false,
                    "icon" : {
                        "image" : "http://www.veryicon.com/icon/16/System/Pleasant/Recycle%20Bin%20e.png"
                    },
                },
                "event" : {
                    "valid_children" : "none",
                    "icon" : {
                        "image" : "http://ouccc.objectis.net/events/aggregator/previous/event_icon.gif"
                    },
                    "start_drag" : true,
                    "move_node" : true,
                    "delete_node" : false,
                    "remove" : false
                }
            },
            "dnd" : {
                "copy_modifier" : false,
                "drag_check" : function (data) {
                    return { 
                        after : true , 
                        before : true , 
                        inside : true 
                    };
                }
            }
        }
        }).bind("rename.jstree", function (e, data) {
            if(prefix!="")
            {
                commitGroupRename(data.rslt.obj.attr("id").substring(11),data.rslt.new_name);
                var text= prefix + data.rslt.new_name;
                $("#jsTree").jstree('rename_node', data.rslt.obj, text );
                prefix="";
            }
        }).bind("loaded.jstree", function (event, data) {
                //$("#jsTree").jstree("open_all");
        }).bind("dblclick.jstree", function (event) {
            var node = $(event.target).closest("li");
            //var data = node.data("jstree");
            if ($(node).attr('rel')=="group" && prefix =='')
            {
                var text = $("#jsTree").jstree('get_text',node);
                prefix = text.substring(0,5);
                text = text.substring(5);
                $("#jsTree").jstree("rename_node", node , text );
                $("#jsTree").jstree("rename",node);
            }
        }).bind("select_node.jstree", function (node, ref_node) {
            var theRealNode = $.jstree._focused().get_selected();
            if (theRealNode.attr('rel')=="group")
            {
                $('#btnRenameSelected').attr("disabled", false);
                $('#btnRenameSelected').removeClass("ui-state-disabled");
            }
            else
            {
                $('#btnRenameSelected').attr("disabled", true);
                $('#btnRenameSelected').addClass("ui-state-disabled");
            }
           });
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月流歌 2024-11-21 10:26:49

已修复 - 正如您所看到的“dnd”实际上位于“types”范围内。哎哟! - 在允许的情况下会接受。

Fixed - as you can see "dnd" is actually inside "types" scope. Doh! - will accept when so allows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文