Reputation: 10694
I'm using jQuery tabs with jQuery cookie.
I'm using jQuery cookie to save the current selected tab, my problem is that I'm using a lot o tabs in my project, and once the selected tab is saved in cookie, is being saved for all of the tabs.
Is there any solution to it? I was thinking about setting dynamic cookie names for every page? But, how do I do that?
$('#tabs').tabs({
cookie: {
expires: 1,
name: // set different cookie name for each #tabs
}});
Any suggestion much appreciated.
Upvotes: 0
Views: 1332
Reputation: 26271
Setting a cookie name
seems to work just fine for me:
$('#tabs').tabs({
cookie:{
expires: 7,
path: '/',
name: '<some variable name>'
}
});
Upvotes: 0
Reputation: 16971
You can't set name to be callable at this time, but you can change cookie option (or any other option passed to .tabs
constructor) by using: http://jqueryui.com/demos/tabs/#method-option
Assuming you initialized tabs, for example by using:
// intitialization
$( "#tabs" ).tabs({
expires: 1, name: 'something'
});
Whenever you need to change cookie name you can do:
// when you want to change cookie option for that tabs
$("#tabs").tabs("option", "cookie", {expires: 1, name: 'booyah'})
// ... somewhere else in your code, change it again, just for fun
$("#tabs").tabs("option", "cookie", {expires: 1, name: 'grandma'})
Upvotes: 1