juven14 / Collapsible

No longer maintaining - Manage multiple collapsibles with cookie support
Other
70 stars 64 forks source link

Collapse all be default #17

Open yorismith opened 10 years ago

yorismith commented 10 years ago

I found this is the best collapsible plugin on the Internet which works perfectly with cookie...I have simple question here...I want to use this plugin with all defaultOpen because I don't seem to get it to work even I tried to specify all section from http://www.snyderplace.com/demos/collapsible.html but they all still not "open" by default...

Thank you for your great work! Yori

cskunk commented 10 years ago

I have the same problem, except I realized that if you use cookies the defaultOpen option is overridden ( please include that in the readme =) ). I can't' figure out how to get them all to default to open with cookies enabled..so that it's pretty much backwards, I want it to save the id's that are supposed to be closed instead of open.

yorismith commented 10 years ago

aahh..no wonder why I can't get it to work...well, if using cookie can't use all "opened" then what the point to use cookie, right? that means cookie is useless on what I am trying to do because it will never worked...I wish we have a ways...

Thank you cskunk

shortguy04 commented 10 years ago

It seems the problem is that the cookie is being created when the page first loads.

If you place the following line right below the declaration of the opts variable in the createCollapsible function, it always returns true, even before the cookie is set later in that same function.

alert(issetCookie(opts));

I'm assuming that something in the issetCookie function is actually creating the cookie as well...?

shortguy04 commented 10 years ago

Ok, easy solution everyone. Change the following line in the issetCookie function:

if ($.cookie(opts.cookieName) === null)

...change it to this:

if ($.cookie(opts.cookieName) == null)

cskunk commented 10 years ago

shortguy04, that didn't work for me =( it still doesn't read the defaultOpen sections when I have the cookies.js loaded