Collapse all nodes except selected when using plus/minus


I have managed to collapse all other nodes when selecting the node text by attaching to the onClick event, but can not get it to work when clicking the plus/minus.

any help is greatly appreciated.



Can suggest you to try such solution:

var selected, tree; tree.loadXML("tree.xml", function(){tree.openItem('books')}); tree.attachEvent("onClick", function(){ selected = tree.getSelectedItemId(); }); tree.attachEvent("onOpenStart", function(id,state){ //debugger; if (id == 'books' && state == 1){ tree.closeAllItems(id); tree.openItem(selected); return false; } return true; });