Select node

537 views
Skip to first unread message

diegofio

unread,
Nov 19, 2010, 6:29:42 AM11/19/10
to jsTree
hi!

sorry for my english

i'm using jstree 1.0 rc3

i want to select a node in the tree by javascript, simulating a user
click.
i use JS click() function on href. so the action associated with the
node is performed, but i can't see the selected style on the node, in
fact it isn't selected.

then i try with select_node event
$('#listaDocumentale').jstree.("select_node", $("#IDOFTHENODE"));


but still doesn't work.

this is my jstree config.

function ricaricajstree(){
$(function () {
$("#listaDocumenti").jstree({
"plugins": ["ui", "themes", "html_data", "search"],
"ui":
{
"select_limit" : 1
},
"themes":
{
"theme" : "classic",
"url" : root + "/styles/elise_jstree.css"
}
})
.bind("search.jstree", function (e, data) {})
.bind("select_node.jstree", function (e, data)
{
eval(data.inst.get_selected()[0].lastChild.getAttribute('href'));
})
.bind("loaded.jstree", function (event, data) {
$("#listaDocumenti").jstree("open_all");
});
});

}

i have to do these operations after a ricaricajstree call because i
must reload all the tree before select the node.
thanks!
Diego

vakata

unread,
Nov 20, 2010, 9:32:01 AM11/20/10
to jsTree
Try using this:

$('#listaDocumentale').jstree("select_node", #IDOFTHENODE");

Or you could:
$("#IDOFTHENODE").children("a").click();

Kindest regards,
Ivan


Kindest regards,
Ivan

diegofio

unread,
Nov 22, 2010, 7:43:50 AM11/22/10
to jsTree
hi ivan, thank you for your answer.
i've already done an automatic click on node href. the click itself
works, but the style of the node doesn't change.
i've just tried your 1st solution but nothing happens


On 20 Nov, 15:32, vakata <ivan.bozha...@gmail.com> wrote:
> Try using this:
>
> $('#listaDocumentale').jstree("select_node", #IDOFTHENODE");
>
> Or you could:
> $("#IDOFTHENODE").children("a").click();
>
> Kindest regards,
> Ivan
>
> Kindest regards,
> Ivan
>
> On 19 îÏÅÍ, 13:29, diegofio <diego.fio...@gmail.com> wrote:
>
> > hi!
>
> > sorry for my english
>
> > i'm using jstree 1.0 rc3
>
> > i want to select a node in the tree by javascript, simulating a user
> > click.
> > i use JS click() function on href. so the action associated with the
> > node is performed, but i can't see the selected style on the node, in
> > fact it isn't selected.
>
> > then i try with select_node event
> > $('#listaDocumentale').jstree.("select_node", $("#IDOFTHENODE"));
>
> > but still doesn't work.
>
> > this is my jstree config.
>
> > function ricaricajstree(){
> > $(function () {
> > š š š š $("#listaDocumenti").jstree({
> > š š š š š š š š "plugins": ["ui", "themes", "html_data", "search"],
> > š š š š š š š š "ui":
> > š š š š š š š š {
> > š š š š š š š š š š š š "select_limit" : 1
> > š š š š š š š š },
> > š š š š š š š š "themes":
> > š š š š š š š š {
> > š š š š š š š š š š š š "theme" : "classic",
> > š š š š š š š š š š š š "url" : root + "/styles/elise_jstree.css"
> > š š š š š š š š }
> > š š š š })
> > š š š š .bind("search.jstree", function (e, data) {})
> > š š š š .bind("select_node.jstree", function (e, data)
> > š š š š {
> > š š š š š š š š š š š š eval(data.inst.get_selected()[0].lastChild.getAttribute('href'));
> > š š š š })
> > š š š š .bind("loaded.jstree", function (event, data) {
> > š š š š š š š š $("#listaDocumenti").jstree("open_all");
> > š š });
Reply all
Reply to author
Forward
0 new messages