View Full Version : Animated Collapsible DIV - setting persistance for site wide

07-11-2007, 10:03 PM
1) Script Title: Animated Collapsible DIV

2) Script URL (on DD):

3) Describe problem:
Hi, the collapsible div script is a wonderful thing, but after looking at the javascript it appears the cookie sets persistance for each page not site wide.

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "")

Wondering if anyone knows how to set the persistance for collapse-expand on 1 div across the site?

Thanks in advance!

07-12-2007, 08:19 AM
That's right, the current persistence feature is page specific, meaning if you have two collapsing DIVs with the same ID (ie: id="mydiv") on two different pages, the two DIVs will be persisted independently of each other.

If you wish the persistence feature to be site wide, firstly, you need to be aware that the ID you assign to your collapsing DIV now becomes a universal identifier of that exact DIV across all pages on your site. In other words, you cannot have two DIVs on two different pages that are not the same DIV use the same ID.

With that in mind, to make the persistence universal, try the following (untested, but should work):

animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")

and changing it to:

animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(thisobj.divId, thisobj.isExpanded)}, "unload")

Then the line:

document.cookie = name+"="+value

and change that to:

document.cookie = name+"="+value+"; path=/"