A bit hard to explain without code, so I have this:
$("#togglelist").toggle(function(){
$("table").addClass("small");
createCookie('list', 'small', 365);
},function(){
$("table").removeClass("small");
eraseCookie('list');
});
var list = readCookie('list');
if (list == 'small') $("table").addClass("small");
As you can see, what I want is for jQuery to set a cookie and remember
when the list is small and display it as small when that cookie is
set. This all works well except that when I have the cookie set and
reload the page, clicking on the <a> that should toggle it executes
the first function() of the toggle, which adds the small class again.
This makes it so one has to click twice on the <a> to
removeClass("small").
I tried a few things but couldn't figure out how to make the toggle()
know not to execute the first function when the cookie is set. I know
there should be an easy way to fix this, something like setting it as
a function and executing that function when the cookie is set, but
when I tried such things i had various errors.
Thanks in advance.
--
Best Regards,
Nate Wienert
_______________________________________________
jQuery mailing list
discuss@jquery.comhttp://jquery.com/discuss/