I apologize for this being an open ended question, but I am at a loss.
Since version 1.9 of the jquery UI, they depreciated using the cookie
option in order to save the active state of tabs across multiple pages. http://jqueryui.com/upgrade-guide/1.9/#deprecated-cookie-option
I haven't seen ANY other documentation out there on how to accomplish this now! So I am left scratching my head.
My best guess would be to use some sort of event
to create a cookie, then load the cookie? Or is there some OTHER way to save the active state of the tabs across multiple pages and by user preference?
Simply:
Had the same issue bite me today. Here is what seems to work:
Use the following code fragment:
This sets a cookie called "activetab" which expires after 10 days (refer to jquery.cookie documentation for more options) to remember the currently selected tab whenever any tab is clicked. This cookie is read at the initialization time to display the last saved tab. The first time the page is visited, the tabs will be collapsed.
You can set the active tab using the active option such as
There are many ways to pass values to a webpage other than cookies. You can use query parameters and hidden fields for example. You would then create an onload script that would read either example using jQuery's onload example. $(function () { }).
To read query strings check out this page which gives you the method
Jquery read query string
and to read a hidden field.
I agree with jquery ui's decision to remove this feature as cookies should really only be used to persist sessions in my opinion and not form fields or tabs for example.
Using localStorage feature of HTML5 gives the solution for the problem, and is now the recommended way to do this type of thing. Cookies cause extra data to be added to every web request and response.
You'll find that localStorage is supported by browsers as archaic as IE8, and if you really really want support for IE6 and IE7, there is a shim to do that.
HTML
JS
And the tabfuntion call
Hope this would be helpful.
event tabsactivate and then store to sessionStorage or localStorage.
Short, layout-independent way of doing this using localStorage:
A layout-specific way of doing it using custom data attributes (possibly useful if the attribute values were to be used in some way elsewhere in your script).
jQuery UI:
Example HTML layout: