nhmvienna / bs5treeview

Bootstrap 5 Treeview
Apache License 2.0
52 stars 24 forks source link

How to reinitialize the bs5treeview? #5

Open mahesh-tier1app opened 2 years ago

mahesh-tier1app commented 2 years ago

Hi,

On my page, I have more than one button. When I click on each button, I need to load the data in the tree view. When I click on any button the very first time then it works fine but after that, if I click on any other button then the data is not loading in a tree.

<div id="tree"></div>

// Assume I am calling the below function whenever any button is clicked
function showTreeView() {

     $('#tree').empty();
     $('#tree').bstreeview({ 
           data: getTreeData()
     });
}

Can you please let me know how can I reinitialize the tree?

Juanillo25 commented 1 year ago

You can do this:

function showTreeView() {

 $('#tree').html('');
 $('#tree').bstreeview({ 
       data: getTreeData()
 });

}