2011-06-14 52 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發佈頁面明天提交,也許會添加一個新的。

無論如何。