Remembering menu status after changing page

Home Forums Older releases 1.0.x Remembering menu status after changing page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2655
    ixnay
    Participant

    Hi guys

    Great menu script, thanks!

    So, I have a collapsed menu:
    https://drive.google.com/file/d/0BzwyGYY9948CRUpxZG9nY3Y3WDA/view

    Is it possible that, when you change to another page, the page reopens with the last opened options instead of opening the menu with the initial status (everything closed)?

    Thanks!

    #2659
    ixnay
    Participant

    Nevermind, I have found a way using cookies / bind events / Jquery show&hide.

    #2716
    robertocalero
    Participant

    Hi, i need the same thing with my menu. But i don’t know how to achieve this. When i click on a menu option, the link loads the new html but when i come back using the back button or a link, the menu option should remain deployed.

    Can you help me? or share part of your code?

    Thanks!

    #2743
    ixnay
    Participant

    Roberto: each time you open up a menu (bind event show) set up a JS cookie with the sub-menu that was opened. Each time you open a page, check if there’s a cookie set up for a menu option and open it through Jquery. Clear the cookie every time a sub-menu is closed.

    #2746
    caveman
    Participant

    Ixnay, can you be so kind and share an example for this newbie 🙂

    I try with this code but i can’t get it work (i use a cookie example from w3c):

    function setCookie(cname,cvalue,exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = “expires=” + d.toGMTString();
    document.cookie = cname+”=”+cvalue+”; “+expires;
    }

    function getCookie(cname) {
    var name = cname + “=”;
    var ca = document.cookie.split(‘;’);
    for(var i=0; i<ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==’ ‘) c = c.substring(1);
    if (c.indexOf(name) == 0) {
    return c.substring(name.length, c.length);
    }
    }
    return “”;
    }

    function checkCookie() {
    var user=getCookie(“username”);
    if (user != “”) {
    // activate the item and focus it
    $(‘#main-menu’).smartmenus(‘itemActivate’, $(‘a#’ + user));
    $(‘a#’ + user)[0].focus();
    // alert(“id menu ” + user);
    } else {
    user = prompt(“Please enter your menu option:”,””);
    if (user != “” && user != null) {
    setCookie(“username”, user, 30);
    }
    }
    }

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?