Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I hope someone might be able to help me out. I have an jQuery animated quicklaunch in which I "remember" the open/closed states through use of jQuery cookies. This works well, with the exception of certain instances.

Basically works as planned on every /path1/SitePages/ wiki page as necessary, however

a) when I navigate to a library link in the same site, /path1/Shared Documents/Forms/ or to /path1/Forms/Forms/AllItems.aspx for instance, the cookies for those sub directories kick in which can be in different open/closed states, messing up the user experience.

I just want one set of cookies to determine the open/closed states of my sharepoint site, not competing sub directory cookies.. how is this possible? below is the code I use to apply the cookie..

            $("#s4-leftpanel-content ul.root>li.static>a.menu-item").click(function(){
            var obj =  $(this);
            var parObj = obj.parent();
            var element = $("ul", parObj);
            var show = $(element).is(":visible")?true:false;

            if(!show) {
                    $(element).addClass("selected");
                    $(element).show('fast');
                    $(element).prev('a').addClass('active');
                    $.cookie($(this).text(), 'expanded');

            } else {
                    $(element).removeClass("selected");
                    $(element).hide('fast');
                    $(element).prev('a').removeClass('active');
                    $.cookie($(this).text(), 'collapsed');
            }
            return false;
share|improve this question
add comment

1 Answer 1

I've figured this out, and it was mostly my doing that it wasn't working. The answer is to set paths

$.cookie($(this).text(), 'expanded', { path: '/path' , domain: "spdomain" });

I was stumbling on this working because in my code I check first if one item was null so I could apply it to be in a default open/closed state, which was messing everything up.

So, if anyone has the same issue, just add the path: and it will set cookies to that path you specify, and not into different subdirectories.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.