Results 1 to 3 of 3

Thread: Simple Tree menu defaults to expanded state

  1. #1
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Tree menu defaults to expanded state

    Simple Tree Menu

    http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

    Hello all,
    hoping that someone have come across and already solved this problem.
    Here's what I'm seeing: Simple Tree Menu ignores its default "all collapsed" settings or the rel="closed" and opens with its subtrees expanded. I can close a subtree manually, but that's not the behavior that I need.
    I have not made any modifications to the code nor the css file. They are fresh from DD. And my test page has nothing else on it just the menu.
    The same incorrect behavior occurs in FF1.5 and IE6.
    Any insight would be much appreciated.

    Here's my page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>

    <script type="text/javascript" src="javascript/simpletreemenu.js">
    /***********************************************
    * Simple Tree Menu- &#169; Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    </script>

    <link rel="stylesheet" type="text/css" href="simpletree.css" />

    </head>
    <body>

    <ul id="treemenu" class="treeview">
    <li><a href="#">services</a>
    <ul>
    <li><a href="#">graphic</a></li>
    <li><a href="#">web</a></li>
    <li><a href="#">photography</a></li>
    <li><a href="#">copywriting</a></li>
    <li><a href="#">direct mail</a></li>
    </ul>
    </li>
    <li><a href="#">portfolio</a></li>
    <li><a href="#">contact us</a></li>
    <li><a href="#">about t.a.</a></li>
    </ul>

    <script type="text/javascript">
    //creates the tree menu
    //ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
    ddtreemenu.createTree("treemenu", false);
    </script>

    </body>
    </html>


    P.S. Looking through the DD code I noticed that none of the lines are terminated with ';' I'm a relative beginner with Javascript but I thought that every statement must end with ';'. What am I missing? Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The ; is optional in javascript, as long as it is obvious (usually due to a line break) where it would belong. However, I see what you mean about this script. Looks like it might be a bug, I will look into it more when I get a chance.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default It's probably a bug but here's a temp solution

    I needed to move on so here's a bandaid that works. Call the ddtreemenu.flatten (treeid, 'contract') function from the last line of the ddtreemenu.createTree function in the simpletreemenu.js like this:


    ddtreemenu.createTree=function(treeid, enablepersist, persistdays){
    var ultags=document.getElementById(treeid).getElementsByTagName("ul")
    ...
    ddtreemenu.dotask(window, function(){ddtreemenu.rememberstate(treeid, durationdays)}, "unload") //save opened UL indexes on body unload
    }
    ddtreemenu.flatten (treeid, 'contract')
    }

    I also changed the .treeview li.submenu ul style to display:block; in the css file. This has the advantage of making the menu javascript independent. If javascript is disabled the entire menu (including subtrees) will be displayed and will remain usable.
    Cheers.
    Last edited by outre2001; 08-30-2006 at 12:54 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •