PDA

View Full Version : Resolved Animated collapsible div v2.4 - cookies?



meek
09-15-2010, 01:56 PM
1) Script Title: Animated collapsible div v2.4

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem: It's not really a problem, I guess... I'm using this great script to toggle the display of a search module. The div is collapsed on page load.
However, when displaying the div and using the search module on my page, the page reloads which obviously causes the div to collapse. I would really like it to stay open/displayed until it's manually closed.

So I'm thinking, would it be possible to make it add a cookie in order to remember it's current state?

ddadmin
09-15-2010, 09:04 PM
Have you tried enabling persistence when initializing your DIVs via persist=1, such as:


<script type="text/javascript">

animatedcollapse.addDiv('jason', 'fade=1,height=80px,persist=1')
animatedcollapse.addDiv('kelly', 'fade=1,height=100px,persist=1')
animatedcollapse.addDiv('michael', 'fade=1,height=120px,persist=1')

animatedcollapse.addDiv('cat', 'fade=0,speed=400,group=pets')
animatedcollapse.addDiv('dog', 'fade=0,speed=400,group=pets,persist=1,hide=1')
animatedcollapse.addDiv('rabbit', 'fade=0,speed=400,group=pets,hide=1')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
}

animatedcollapse.init()

</script>

meek
09-20-2010, 12:37 PM
Hi, and thanks for the reply.
That's exactly what I was looking for. I can't believe I missed that attribute in the first place. It works perfectly.

Thanks again. :)