Ready to get started?Download WordPress


JQuery Sidebar Cookie Question (8 posts)

  1. Justin Tadlock

    Posted 7 years ago #

    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() {
  2. Justin Tadlock

    Posted 7 years ago #

    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.

  3. sfong15
    Posted 7 years ago #

    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 http://template.sfong.net/?p=75

  4. Justin Tadlock

    Posted 7 years ago #

    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.

  5. sfong15
    Posted 7 years ago #

    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.

  6. Justin Tadlock

    Posted 7 years ago #

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

  7. sfong15
    Posted 7 years ago #

    greenshady, what you are looking for is here

  8. Justin Tadlock

    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic