Dec
29
Posted on 29-12-2006
Filed Under (AJAX ) by jay

This is an up date to Using Script.aculo.us to Toggle a DIV with the added bonus of persisting the state of the Toggled DIV(s). This is not as an elegant solution because it doesn't to use the Effect.Toggle Function but it does allow you to use any pair of Combination Effects.

First a shout out to Cookies in JavaScript and Unobtrusive & Persistent Script.aculo.us Effects for the JavaScript Cookies code.

Due to the need to have a window.onload function in the script I cannot demo it in Wordpress but I can demo it here.

View Source Code

    Read More   

Comments

Fluffy on 28 February, 2007 at 7:58 pm #

Wow; I just stumbled onto this via Pixel Groovy, and it's a solution I've been racking my brain to try to figure out for the last week. I'm really looking forward to putting this to use, thanks for the posts!


[...] ich habe irgendwo gelesen, dass man cookies nehmen könnte. hier wäre z.b. eine solche lösung: you.gotfoo.org » Blog Archive » Using Script.aculo.us to Toggle a DIV II kann mir jemand bei der umsetzung helfen? wo müsste der code rein? in den header oder in den [...]


allos on 22 March, 2008 at 11:49 am #

i tested your script and it works fine , but what if i want the divs to be open as an initial state

so the users could close any content that they don't want ?

i try to change the

to

but it doesn't work


anonyme on 6 April, 2008 at 7:44 pm #

Hi all, I use this:
________________________________
var boxIds = getElementsByClassName('tabC');
________________________________

to retrieve all DIVs or SPANs without specifying IDs for each DIV, it works fine.
Still, while I see the online example works, I have no luck at all with cookies and it doesn't remember the positions of my DIVs. Maybe a wrong Prototype/scriptaculous version?

Thanks to the author anyway


anonyme on 6 April, 2008 at 7:58 pm #

A correction: this is the only way for me to REALLY make the persistence with automatic retrieving of ids by class name (but you still have to specify an id):
___________
var boxIds = document.getElementsByClassName('tabC');
for (i = 0; i


Post a Comment
Name:
Email:
Website:
Comments: