Log in

View Full Version : One and Only one Div open on switch content script



shopsteward
04-27-2007, 07:43 PM
1) Script Title: Switch Content Script

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

3) Describe problem: I would like to set this up so that there is always at least one div expanded and only one div expanded. That is to say I would like to have my default div expand if someone closes the only open Div. Alternately I would like to disable the ability of a user to close the currently open div. it would close if someone opened another div, but there should always be one and only one Div open.

how can I alter the script to make this happen?

thanks!

shopsteward
04-30-2007, 06:45 PM
I'm bumping this to the top. still hoping for some help.

Veronica
04-30-2007, 08:26 PM
You make the change in the javascript at the end of the page. Set it to true

joeexample.collapsePrevious(true)

False allows more than 1 content to be open simultanously. True allows only one set of content to be open at any time.

shopsteward
04-30-2007, 09:24 PM
Yes I understand that, but it also allow zero to be open. I would like it to open the default when all others hae been closed.

-s

jscheuer1
05-01-2007, 03:16 AM
I think I got this worked out pretty well. I added a public function:



instance.keepOneOpen(Boolean)

Specifies whether one content should always be expanded no matter what.

Parameter:
Boolean: true or false

It works well with the other options as far as I can tell. Except not with the expand all or contract all functions. For example, it works with the demo's joeexample, but not with the bobexample.

For this to work out, numerous additions to the script were required. So, I will attach the updated switchcontent.js script below. One other item of interest - the content that will always be open defaults to the first content. But, if:


instance.defaultExpanded(indices)

is specified, it will use the first index. Indices may be specified in any order.

Here's the updated script (unzip the below and replace your switchcontent.js with it):

999

shopsteward
05-01-2007, 03:29 PM
Oh fantastic!

It seems to work great. You hae saned my life

-s