Results 1 to 3 of 3

Thread: SD Menu - Initial collapse vs persistence

  1. #1
    Join Date
    Dec 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default SD Menu - Initial collapse vs persistence

    1) Script Title: Slashdot Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/slashdot.htm

    3) Describe problem:

    I looked through the previous SD menu thread and saw some people address this issue, however it was on an earlier version of SD menu.

    The issue is that I'd like to have the menu completely collapsed the first time someone visits the site (or deletes their cookies/cache). But once someone starts navigating the site they can have a submenu collapsed or expanded.

    I currently have :

    function SDMenu(id) {
    if (!document.getElementById || !document.getElementsByTagName)
    return false;
    this.menu = document.getElementById(id);
    this.submenus = this.menu.getElementsByTagName("div");
    this.remember = true;
    this.speed = 3;
    this.markCurrent = true;
    this.oneSmOnly = true;

    Any help or links to a solution are much appreciated!

    Also thanks for the great menu DimX!

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    If it's not too much trouble, you could try one of these:
    http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm
    Then, all you need to do to get the desired effect is to make sure these settings look like this: defaultexpanded: [] and persiststate: true which means all tabs are collapsed as a default when the browser session starts, but the states remain persistent during the session.

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    In the code:
    Code:
    var firstSubmenu = myMenu.submenus[0];
    myMenu.expandMenu(firstSubmenu);      // Expand a submenu
    myMenu.collapseMenu(firstSubmenu);    // Collapse a menu
    myMenu.toggleMenu(firstSubmenu);      // Expand if collapsed and collapse if expanded
    
    myMenu.expandAll();                   // Expand all submenus
    myMenu.collapseAll();                 // Collapse all submenus
    Either change the highlighted to your desired code or change that whole section to:
    Code:
    var myMenu = new SDMenu("main_menu"); // ID of the menu element
    // Default values...
    myMenu.speed = 3;                     // Menu sliding speed (1 - 5 recomended)
    myMenu.remember = true;               // Store menu states (expanded or collapsed) in cookie and restore later
    myMenu.oneSmOnly = false;             // One expanded submenu at a time
    myMenu.markCurrent = true;            // Mark current link / page (link.href == location.href)
    
    myMenu.init();
    
    myMenu.collapseAll();                 // Collapse all submenus
    Although that would have to go in the onload with myMenu.init()(the selected).
    Jeremy | jfein.net

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
  •