Save warehouse state on jQuery tabs

I am using jQuery dropable tabs. I was wondering how to save the state of my minimized option (maximized or minimized) for subsequent requests (page loading) in cookies. The idea is that if I refresh the page and the tab has been minimized, I should see it minimized.

+4
source share
3 answers

Besides cookies?

Of course, you can use cookies, but there are other ways to do this:

Just say that you can use other tools that are saved with full page requests ...

+2
source

you can use the cookie option built directly into the plugin. Initialize tabs with the specified cookie option.

 $( ".selector" ).tabs({ cookie: { expires: 30 } }); 

Get or set the cookie parameter after init.

 //getter var cookie = $( ".selector" ).tabs( "option", "cookie" ); //setter $( ".selector" ).tabs( "option", "cookie", { expires: 30 } ); 

Docs

+13
source

a hash method a go! may be provided

use this plugin http://benalman.com/projects/jquery-hashchange-plugin/ (you really do not need this, but it saves you from writing a few more lines)

When you click on expand, it should add # hash.class to url

than you determine if window.location class has a class, if it does, expand it.

But this method only works with one maximizer at a time.

+1
source

Source: https://habr.com/ru/post/1400800/


All Articles