JQuery treeview - add node(s) in middle of tree
Posted
by Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-03-25T12:11:28Z
Indexed on
2010/03/25
12:13 UTC
Read the original article
Hit count: 504
Hi all,
I'm just getting started with JQuery and the treeview plugin so this should be a relatively easy question:
The example code for adding branches to the tree:
var newnodes = $("<li><span class='folder'>New Sublist</span><ul>" +
"<li><span class='file'>Item1</span></li>" +
"<li><span class='file'>Item2</span></li></ul></li>").appendTo("#browser");
$("#browser").treeview({
add: branches
});
Works fine for me, but adds the new branch at the end of the tree - instead what I want is to be able to select a specific node and add to that branch. I've managed to get the node being added by using the id of the particular node instead of the whole treeview in - appendTo("nodeID") However I can't get the tree to render correctly, either with:
$("nodeID").treeview({
add: branches
});
or
$("browser").treeview({
add: branches
});
or calling it on both without arguments.
Cheers in advance
© Stack Overflow or respective owner