[EMAIL PROTECTED] wrote:
Hi, having some small troubles with the tabs plug-in from Klaus Hartl
(http://www.stilbuero.de/jquery/tabs/).
I'm trying to implement his cookies plug-in (see code below) and can't
seem to get the tabs to change to the defined tab using the method
"Start With Custom Tab" [code example: $('#container-1).tabs(2);].
As you can see in the code below, I'm trying to start with a custom
tab defined by "$.cookie(TABS_COOKIE)||1". This should look up the
cookie and set the value if any, if not, the default is 1.
The cookie plug-in is working because I can view the cookie through my
browser, any ideas?
--CODE--
// create variable for cookie
var TABS_COOKIE = 'tabs_cookie';
// create tabs, add effects, check for cookie and set to correct tab
$("#container-1").tabs($.cookie(TABS_COOKIE)||1,{
onClick: function(clicked){
var lastTab = $
(clicked).parents("ul").find("li").index(clicked.parentNode) + 1;
$.cookie(TABS_COOKIE, lastTab);},
fxSlide: true,
fxFade: true,
fxSpeed: "normal"
});
--END CODE--
I think the problem is that $.cookie returns a string, but tabs()
requires a number for the initial tab. Try:
$("#container-1").tabs(parseInt($.cookie(TABS_COOKIE)) || 1, {
...
});
--Klaus