View Full Version : Simple Tree Menu
08-25-2008, 09:41 PM
1) Script Title:
Simple Tree Menu
2) Script URL (on DD):
3) Describe problem:
Another question is, how do I make it possible that when I click on Folder1 it expands but it closes Folder2 (which was open). So is it possible that there is maximum one expanded Folder at the same time?
If you can help me that would be grate! Specially cause I think it's a very usefull en fast script. Thx
08-26-2008, 03:58 AM
For #1, try the attached modified .js file. Then, within your HTML, give the subtree (the LI element) an ID, and call ddtreemenu.manualexpand() to expand it:
<ul id="treemenu1" class="treeview">
<li>Sub Item 1.1</li>
<li>Sub Item 1.2</li>
<li>Sub Item 2.1</li>
<li id="mysubtree">Folder 2.1
<li>Sub Item 2.1.1</li>
<li>Sub Item 2.1.2</li>
//ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
<a href="#" onClick="ddtreemenu.manualexpand('mysubtree'); return false">Expand sub tree</a>
For #2, there's unfortunately no easy way to have one subtree collapse when the current one is open, unlike for example Switch Content script (http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm). I'll most likely add in such a feature the next time the script is updated.
08-26-2008, 08:57 PM
#1 It's perfect, just great! Even works within the asp-code!
#2 I'm looking forward to the update :cool:
Lots of appreciations :):):)
Many thanks for the quick answer!
09-02-2008, 08:18 AM
I myself was looking for the solution for your second problem and after reading this post decided too give it a try myself since it didn't exist yet.
I've created the function contractRest by taking a good look at the flatten function.
ddtreemenu.contractRest = function(treeid, ulelement)
var ultags = document.getElementById(treeid).getElementsByTagName("ul")
for (var i=0; i<ultags.length; i++)
ultags[i].style.display=(ulelement==ultags[i])? "block" : "none"
var relvalue = (ulelement==ultags[i])? "open" : "closed"
ultags[i].parentNode.style.backgroundImage = "url("+ddtreemenu.closefolder+")"
I call this on the onclick open event:
ulelement.parentNode.onclick = function(e)
I've only tested this for the particular site I'm using it on, haven't tested on a "standard" tree menu.
Hope it helps.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.