settings jquery tabs cookies

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

settings jquery tabs cookies

Post by pcoder »

Hi All,
I have used this code for UI tabs.

http://jqueryui.com/demos/tabs/

I tried to get back the last visited tabs after page refresh using cookies. But I failed to set cookies here.
Any thoughts on this?

Thanks
User avatar
lord_webby
Forum Commoner
Posts: 44
Joined: Wed Aug 19, 2009 9:01 am

Re: settings jquery tabs cookies

Post by lord_webby »

http://jqueryui.com/demos/tabs/#event-enable

Modify the click event to store the currently selected tab - then use the click function using the windows onload property to enable the tab you want

Code: Select all

var $tabs = $('#example').tabs(); // first tab selected
 
$('#my-text-link').click(function() { // bind click event to link
    $tabs.tabs('select', 2); // switch to third tab
    return false;
});
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: settings jquery tabs cookies

Post by pcoder »

Thanks for your reply.
But I solved it by writing this line of code:

Code: Select all

$('#tabs').tabs({ cookie: { expires: 30 } });
Thanks again.
Post Reply