Estoy tratando de escribir algún código que agregue nodos a un jstree de forma dinámica. He seguido el documento al http://www.jstree.com/documentation/crrm pero no puedo obtener un ejemplo simple para trabajar: se está agregando el nodo child2, pero se está agregando al nodo 'root.id' en vez de 'child1.id' como se especificó. .. Algunos consejos podrían ser muy apreciados. Código sigueAgregando de forma programada nodos secundarios a un jstree
<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" },
function() { alert("added"); }, true);
});
});
</script>
</head>
<body>
<div id="tree" name="tree"></div>
<input type="button" id="add" value="add" />
</body>
</html>
Para mí, la operación "crear" no funcionó ... I sp ecified "create_node" y funcionó! –
Por lo que vale, no pude hacer que 'create' funcione tampoco. Si bien 'create_node' sí funcionó, creo que los parámetros deben ser diferentes. Seguramente estaría bien si su documentación no fuera tan inútil. ¿Sabes dónde puedo encontrar documentación sobre el método 'create_node'? – Brad
http://www.jstree.com/documentation Ir al hipervínculo de documentos centrales – Ashwin