Results 1 to 3 of 3

Thread: Switch Content - always have 1 group expanded

  1. #1
    Join Date
    Jun 2010
    Posts
    58
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Switch Content - always have 1 group expanded

    1) Script Title: Switch Content Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tchcontent.htm

    3) Describe problem: Hi,
    I just finished setting up the switch content script on this site page: http://www.promisefoundation.org/newsite/awareness.php

    I would like to always have 1 group expanded (so that each will only contract when swapped with another). No more than one should be open at a time. And I am not worried about whether or not persist works.

    Any help would be much appreciated. Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,994
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    I see you've already modified the switchcontent.js file to include some image swapping. And, as it turns out I already had a version of this script that includes a keepOneOpen() function. But it was from before the AJAX update. However, you're not using that. So here's what to do. Download and use this version of the script to which I've already added your swap() function modifications (right click and 'Save As'):

    switchcontentonemust.js

    Then in the on page init for the script, change:

    Code:
    <script type="text/javascript">
    // MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
    // Call Instance.init() at the very end. REQUIRED
    
    var promiseexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
    promiseexample.setColor('darkred', 'black')
    promiseexample.setPersist(true)
    promiseexample.collapsePrevious(true) //Only one content open at any given time
    promiseexample.init()
    </script>
    to:

    Code:
    <script type="text/javascript">
    // MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
    // Call Instance.init() at the very end. REQUIRED
    
    var promiseexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
    promiseexample.setColor('darkred', 'black')
    promiseexample.keepOneOpen('remain')
    promiseexample.collapsePrevious(true) //Only one content open at any given time
    promiseexample.defaultExpanded(0)
    promiseexample.setPersist(true)
    promiseexample.init()
    </script>
    The browser cache may need to be cleared and/or the page refreshed to see changes.
    - John
    ________________________

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

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    katebellami (05-16-2013)

  4. #3
    Join Date
    Jun 2010
    Posts
    58
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Worked like a charm! As always, thank you and you are awesome!!

Similar Threads

  1. Switch Menu fully expanded at start
    By button1 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 04-13-2010, 12:48 PM
  2. Switch content hide link inside the expanded div
    By yahooman122 in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 04-04-2009, 08:18 PM
  3. Switch Content Expand Single Group
    By rhoadesm in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-08-2008, 11:32 PM
  4. Switch Content Script: modify default expanded array
    By majocmatt in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-20-2007, 12:21 AM
  5. Switch Menu II: How to view one expanded menu at a time
    By gazanson in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 09-04-2006, 09:23 AM

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
  •