开发者

jsTree copy_modifier : false -- Does Not prevent node copy!

开发者 https://www.devze.com 2023-03-11 11:07 出处:网络
Here is my code, its supposed to prevent node copy when using ctrl key, but it still allows copy and doesn\'t prevent it.

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" : {
                    "vali开发者_如何学God_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");
            }
           });
});


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号