Page 1 of 1

settings jquery tabs cookies

Posted: Mon Sep 14, 2009 3:57 am
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

Re: settings jquery tabs cookies

Posted: Mon Sep 14, 2009 4:08 am
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;
});

Re: settings jquery tabs cookies

Posted: Tue Sep 15, 2009 3:29 am
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.