PDA

View Full Version : Drop Down Panel: How To Control State On Each Page?



tekneck
03-23-2010, 12:46 PM
I need to have my panel open by default on my home page and then allow visitors to open and close it (with persistence) after that...

http://www.dynamicdrive.com/dynamicindex17/dddropdownpanel.htm

How can I tell the panel to be open on the home page? And initially closed on others initially until the user closes it?

Adding the code below to my page, either above or below the panel code does not seem to make a difference...



<script type="application/javascript">defaultpanel.togglepanelplus('down');</script>

What is the best way to control it's state when a page is loaded?

Thanks!

Code Red
03-25-2010, 02:24 PM
I would also like a solution to this as well, it would be useful to be able to define the state of windows when the page loads.

Any ideas?

ddadmin
03-27-2010, 03:53 AM
Try the below modified .js file. With it, to get the Drop Down Panel on a specific page to be opened by default, edit its configuration code by adding the part in red:


var defaultpanel=new ddpanel({
ids: ["mypanel", "mypanelcontent", "mypaneltab"], // id of main panel DIV, content DIV, and tab DIV
stateconfig: {initial: "5px", persiststate: true, initialstate:"open"}, // initial: initial reveal amount in pixels (ie: 5px)
animate: {enabled: true, steps: 5}, //steps: number of animation steps. Int between 1-20. Smaller=faster.
pointerimage: {enabled: true, src: ["arrow-down.gif", "arrow-up.gif"]},
closepanelonclick: {enabled: true} // close panel when links or elements with CSS class="closepanel" within container is clicked on?
})

Code Red
03-30-2010, 10:44 AM
Brilliant! Thanks so much for this.

Code Red
03-30-2010, 11:04 AM
Whoops... spoke a little too soon - the initial panel state works initially, but from then onwards it toggles between the open and closed state each time the page is refreshed.

If I set persiststate to false the panel remains open all the time, but that's not how I'd like it to work really - I'd like the panel to be open as a default when the site opens, but if the visitor then closes that panel I'd like it to stay closed.

Sorry to be picky!

ddadmin
03-30-2010, 10:17 PM
You're right, there are some bugs in that version. Try the below one instead...

Code Red
03-31-2010, 09:43 AM
Much better, thanks again!