2011-06-14 48 views
4

我已经按照http://www.jstree.com/demo/types的最后一个示例中的代码片段创建给定类型的节点,我不知道它为什么不起作用。jsTree不创建特定类型的节点

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:

$(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( “创造”,NULL, “内部”,{。 “attr”:{“rel”:“parameter”}});

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

预先感谢您。

UPDATE

http://osdir.com/ml/jstree/2011-04/msg00126.html使用指令解决。 明确列出所有有效的孩子(而不是使用“全部”)解决了问题。

我会检查一个类似的错误是否在jsTree发布页面明天提交,也许会添加一个新的。

无论如何。

回答

2

只是重复上述UPDATE如要求被一些人:

http://osdir.com/ml/jstree/2011-04/msg00126.html使用说明书解决。明确列出所有有效的孩子(而不是使用“全部”)解决了这个问题。

我会检查一个类似的错误是否在jsTree发布页面明天提交,也许会添加一个新的。

无论如何。