Ho un codice in cui ho bisogno della possibilità di aggiungere nodi figlio a un jstree che a loro volta contiene figli. Il codice seguente aggiunge un nodo "child2" correttamente a "child1" ma ignora i dati child3. Qualsiasi aiuto molto apprezzato. Il codice segue:jstree - aggiunta di nodi figlio che contengono essi stessi bambini
<html>
<head>
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.jstree.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function() {
$("#tree").jstree({
"json_data" : {
"data" : [
{
"data" : "parent",
"attr" : { "id" : "root.id" },
"children" : [ { "data" : "child1",
"attr" : { "id" : "child1.id" },
"children" : [ ] }
]
},
]
},
"plugins" : [ "themes", "json_data", "crrm" ]
});
});
$("#add").click(function() {
$("#tree").jstree("create", $("#child1\\.id"), "inside",
{ "data" : "child2", "attr" : { "id" : "child2.id" },
"children" : [ { "data" : "child3", "attr" : { "id" : "child3.id" }, "children": [ ] } ] },
function() { alert("added"); }, true);
});
});
</script>
</head>
<body>
<div id="tree" name="tree"></div>
<input type="button" id="add" value="add" />
</body>
</html>
Forse questo non è possibile? Presumemmo che la funzione di creazione fosse implementata per recitare sui bambini, ma forse no ... Andando a dare un'occhiata alla fonte ... – user419766
ho avuto lo stesso problema come hai potuto risolverlo? –