chniter / bstreeview

Bootstrap Treeview, A very simple plugin to build a basic and elegant Treeview with bootstrap 4. See the demo:
https://chniter.github.io/bstreeview/
Apache License 2.0
367 stars 53 forks source link

How can i add a new tree to the same div? #25

Open LaNoriainnova opened 3 years ago

LaNoriainnova commented 3 years ago

im building a dynamic tree for this i call a method which builds the tree, but when i call the same function so it can build the new tree when a get to the part of $('#tree').bstreeview({data: json}); it dosen't do nothing

// this is just an example

function buildsTreeDyanamic(){ // the values of this json changes every time the function is call var mydynamictree = [ { icon: "fa fa-globe fa-fw", text: "Go to Google", class: "text-info", href: "https://google.com" } ]; // it does print the tree ithe first time, but when a clean that div and call the function again the tree dosen´t appear $('#tree').bstreeview({data: mydynamictree }); }

revolution-webmaster commented 3 years ago

Did you find a solution for this? I'm having the same issue.

sunnysonic commented 2 years ago

same problem....

Mjalid commented 2 years ago

same problem.... is there a solution to refresh or reload a dynamic tree Thanks

salihahmp commented 2 years ago

$('#treeview').empty(); //to empty the div $('#treeview').removeData(); // to recall the js function (need to put or else it will not show any treeview) I add above code before calling .bstreeview function and it works. $('#treeview').bstreeview({ data: bor, //expandIcon: '', //collapseIcon: '', indent: 1.25, parentsMarginLeft: '1.25rem', openNodeLinkOnNewTab: true, });