jquery question cookie

hi all

i currently have this jquery tab set up  http://jqueryui.com/demos/tabs/
but i would like to set a cookie to save the link last used for when the page reloads.
i have taken a look at this http://jqueryui.com/demos/tabs/#cookie
but cant find a example of code for setting the cookie.

how do i set this cookie ?
LVL 1
helpchrisplzAsked:
Who is Participating?
 
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
I'm sorry, I misread the question.

The tabs feature for jQuery UI will automatically set the cookie for you, as long as you tell it to.   If you look at the source for the cookie persistance, you'll see:

<script>
$(function() {
	$( "#tabs" ).tabs({
		cookie: {
			// store cookie for a day, without, it would be a session cookie
			expires: 1
		}
	});
});
</script>

Open in new window

0
 
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
Here's a good blog post on how to manage cookies with javascript: http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html

It shows both a conventional way and the jQuery way.   HTH.
0
 
helpchrisplzAuthor Commented:
ok so i have this but its not saving the tab on page reload. ?




<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>


 <script>
$(function() {
      $( "#tabs" ).tabs({
            cookie: {
                  // store cookie for a day, without, it would be a session cookie
                  expires: 1
            }
      });
});
</script>
   
      <div class="demo">
        <div id="tabs">
       
       

          <ul>
            <li><a href="#tabs-1">Appointment options</a></li>
            <li><a href="#tabs-2">Add or remove patient</a></li>
            <li><a href="#tabs-3">Practitioner options</a></li>
            <li><a href="#tabs-4">Treatment options</a></li>
          </ul>
          <div id="tabs-1">Appointment options</div>
<div id="tabs-2">Add or remove patient</div>
<div id="tabs-3">Practitioner options</div>
<div id="tabs-4">Treatment options</div>
</div>
</div>
0
 
helpchrisplzAuthor Commented:
ok it seems to be working now :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.