Link to home
Start Free TrialLog in
Avatar of helpchrisplz
helpchrisplz

asked on

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 ?
Avatar of Phil Phillips
Phil Phillips
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of Phil Phillips
Phil Phillips
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of helpchrisplz
helpchrisplz

ASKER

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>
ok it seems to be working now :)