Results 1 to 6 of 6

Thread: One and Only one Div open on switch content script

  1. #1
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question One and Only one Div open on switch content script

    1) Script Title: Switch Content Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tchcontent.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!

  2. #2
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm bumping this to the top. still hoping for some help.

  3. #3
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I think I got this worked out pretty well. I added a public function:

    Code:
    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:

    Code:
    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):

    Attachment 999
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh fantastic!

    It seems to work great. You hae saned my life

    -s

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •