Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save collapsible state on jQuery tabs

I am using jQuery tabs with the collapsible option. I was wondering how to save the state of my collapsible option (maximized or minimized) across subsequent requests(page loads), within a cookie. The ideas is if I refresh the page and the tab was minimized then i should see it minimized.

like image 934
johnny j Avatar asked Dec 04 '22 17:12

johnny j


1 Answers

you can use the cookie option built right into the plugin, Initialize a tabs with the cookie option specified.

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

Get or set the cookie option, after init.

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

DOCS

like image 185
Rafay Avatar answered Dec 21 '22 22:12

Rafay