Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reload/refresh/reinit DynaTree?

When I do the following

$('#tree').dynatree("option","initAjax",{url:"http://google.com"});

I want dynatree to forget about current tree data and reload with new data from the specified url instead. But I find it does not do that by default.

Thanks.

like image 562
Mr Coder Avatar asked Sep 06 '11 10:09

Mr Coder


3 Answers

look at the tree.reload() method, it should do what you are after.

see the docs here: http://wwwendt.de/tech/dynatree/doc/dynatree-doc.html#h8.2

as in the docs, the tree is the internal drawing of the tree, and you get it by calling the getTree command: $("#node").dynatree("getTree")

like image 137
longstaff Avatar answered Oct 17 '22 15:10

longstaff


tree.reload(); is for data loaded dynamically as in Ajax. If you are working with ul/li lists and need to reload your tree, you have to do: $("#tree").dynatree("destroy"); before your regular dynatree creation code. The destroy parameter is not documented.

like image 20
movAX13h Avatar answered Oct 17 '22 17:10

movAX13h


Function the initialization:

function InitTree() {
   $("#tree3").dynatree({
       (...init params...)
   });
}

InitTree();

To reload data, call:

$("#tree3").dynatree("destroy");
InitTree();
like image 5
Arvy Avatar answered Oct 17 '22 16:10

Arvy