• I’m making a theme that has collapsible/expandable sidebar sections. I’m using jQuery for this process.

    Since I’m still a newbie to jQuery, I was wondering if anyone knew how to set a cookie to keep the sidebar sections set the same after the page is reloaded or the user comes back later.

    Here’s the code I’m using to manage the collapsing/expanding:

    // Expand and collapse sidebar
    $(document).ready(function() {
    	$('#sidebar').find('h2').click(function() {
    		$(this).next().slideToggle(10);
    	});
    });
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Justin Tadlock

    (@greenshady)

    So, I’m going to assume no one’s familiar with jQuery around here.

    This is going to be a really, really cool theme. If I can’t get this done, I suppose I won’t be able to share it with the world.

    I don’t know any answer but I have played with jQuery for a little while. I followed one of their example at the site. The trouble with that is that you click to expand one section but every other sections will also be expanded. I guess it’s hard for me to write javascript to add id to each collapsible section such that only one is expanded when clicked while opened one will be closed…etc.

    I used something else, see my way here https://template.sfong.net/?p=75

    Thread Starter Justin Tadlock

    (@greenshady)

    Actually, it doesn’t expand all the other sections. That’s what the “ $(this).next()” is for. It means to just expand/collapse the next element.

    I’ll check out your link when I have a little extra time.

    greenshady, I’ll look out for your solution using jQuery. In fact I’m playing with another blogware which comes with jQuery. It’s nice to use library already available.

    Thread Starter Justin Tadlock

    (@greenshady)

    Thanks, I’m still at a loss. I never learned Javascript, and jQuery has been easy to pick up.

    greenshady, what you are looking for is here

    Thread Starter Justin Tadlock

    (@greenshady)

    That’s a good example, but not what I’m looking for. I need to save the state of the expanded/collapsed elements in a cookie.

    I have the expanding/collapsing working.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘JQuery Sidebar Cookie Question’ is closed to new replies.