jsTree没有创建特定类型的节点 [英] jsTree not creating node of an specific type

查看:99
本文介绍了jsTree没有创建特定类型的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了 http://www.jstree.com/的最后一个示例中的代码片段.演示/类型创建给定类型的节点,我不知道为什么它不起作用.

I've followed the code fragment in the last example of http://www.jstree.com/demo/types to create a node of a given type and I've got no idea why it doesn't work.

HTML片段:

    <form>
        <button id="buttonAddMenu" type="button">Créer Menu</button>
        <button id="buttonAddParameter" type="button">Créer Paramètre</button>
        <button id="buttonRename" type="button">Renomer</button>
        <button id="buttonRemove" type="button">Supprimer</button>
        <button id="buttonShowData" type="button">Show Data</button>
    </form>
    <div id="checkListParams">
    <ul>
        <li id="new001"><a href="#">Root menu 1</a></li>
        <li id="new002"><a href="#">Root menu 2</a>
            <ul>
                <li><a href="#">Menu 2.1</a></li>
                <li><a href="#">Menu 2.2</a>
                    <ul>
                        <li rel="parameter"><a href="#">Parameter A</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
    </div>

JavaScript:

Javascript:

$(document).ready(function() {
//================
//Configuring tree
//================
$("#checkListParams").jstree({ 
    "ui" : {
        "select_limit": 1
    },
    "contextmenu" : {
        "select_node": true
    },
    "hotkeys" : {
        "del": false //disable deleting nodes only via DEL key
    },
    "types" : {
        "valid_children" : [ "default" ],
        "use_data" : true,
        "types" : {
            "default" : {
                "valid_children" : [ "all" ]
            },
            "parameter" : {
                "icon" : { 
                    "image" : "site/media/img/icons/checklist_parameter.png" 
                },
                "valid_children" : [ "none" ],
                "create_node": false
            }
        }
    },
    "core" : { "initially_open" : [ "all" ] },
    "plugins" : [ 
    "themes", "html_data", "xml_data", "ui", "crrm", "dnd", 
    "contextmenu", "hotkeys", "types"
    ]
});

//==========================
//Configuring button actions
//==========================
$("#buttonAddMenu").click(function() {
    $("#checkListParams").jstree("create");
});

$("#buttonAddParameter").click(function() {
    //$("#checkListParams").jstree("create", null, "inside"); //works!
    $("#checkListParams").jstree("create", null, "inside", { "attr" : { "rel" : "parameter" } });
});

$("#buttonRemove").click(function() {
    $("#checkListParams").jstree("remove");
})

$("#buttonRename").click(function() {
    $("#checkListParams").jstree("rename");
})

$("#buttonShowData").click(function() {
    var nodes = $("#checkListParams").jstree("get_xml", {
        "li_attr" : [ "id" , "class", "rel" ]
    });
    alert(nodes);
})

});

$(#checkListParams").jstree("create",null,"inside",{"attr":{"rel":"parameter"}}});

$("#checkListParams").jstree("create", null, "inside", { "attr" : { "rel" : "parameter" } });

不起作用.我试图将类型更改为默认",但没有成功...而且,我也没有错误消息(我不喜欢在事情不运行时不收到错误消息).

is not working. I've tried to change the type to "default", without success... Also, I've got no error messages (I don't like not getting error messages when things don't run).

谢谢.

更新

已使用 http://osdir.com/ml/jstree/中的说明进行了解决2011-04/msg00126.html . 显式列出所有有效子代(而不是使用"all")解决了该问题.

Solved using instructions in http://osdir.com/ml/jstree/2011-04/msg00126.html . Explicitly listing all valid children (instead of using "all") solved the problem.

明天我将检查jsTree问题页面中是否存在类似的错误,也许还会添加一个新错误.

I'll check whether a similar bug is filed in jsTree issues pages tomorrow, maybe adding a new one.

还是谢谢.

推荐答案

只需按照某些人的要求重复上述UPDATE:

Just repeating the above UPDATE as asked by some people:

已使用 http://osdir.com/ml/jstree/中的说明进行了解决2011-04/msg00126.html .显式列出所有有效子代(而不是使用"all")解决了这个问题.

Solved using instructions in http://osdir.com/ml/jstree/2011-04/msg00126.html . Explicitly listing all valid children (instead of using "all") solved the problem.

明天我将检查jsTree问题页面中是否存在类似的错误,也许还会添加一个新错误.

I'll check whether a similar bug is filed in jsTree issues pages tomorrow, maybe adding a new one.

还是谢谢.

这篇关于jsTree没有创建特定类型的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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