Results 1 to 5 of 5

Thread: switch content script

  1. #1
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default switch content script

    Im having a problem with switch content script http://www.dynamicdrive.com/dynamici...tchcontent.htm
    I made it on my website so on the left I have menu with headers, each has different ID, like s1-title, s2-title, i have like 15 of them
    then on the right i have box where content is displayed, with 15 div's, like <div id="s1" class="helpcont">, ID is different for each, class is the same.

    problem is that I cant set default expanded div with content when i add line "instance.defaultExpanded(0)", it just expands all the content div's at the same time. afaik (0) here means index number of the content div. shall i set it somehow in this case?

    Code:
    the script part:
    <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 bobexample=new switchcontent("helpcont", "div") //Limit scanning of switch contents to just "div" elements
    bobexample.setColor('#ff6600', '#4d4d4d')
    bobexample.setPersist(false)
    bobexample.collapsePrevious(true) //Only one content open at any given time
    instance.defaultExpanded(0)
    bobexample.init()
    </script>
    Last edited by ddadmin; 08-27-2012 at 11:47 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    DD Admin

  3. #3
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    its here:
    http://kupishmot.ru/index.php?p=howto
    menu is on the left.
    how can I make one of these menu headers display by default?
    thanks.. Nick.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm your set up at a glance looks correct. The only thing that could be interfering with the default expanded setting is your enabling of persistence inside the initialization code. That, plus the default expanded setting being commented out at the moment (perhaps intentional on your part). With that said, try the following initialization code:

    Code:
    var bobexample=new switchcontent("helpcont", "div") //Limit scanning of switch contents to just "div" elements
    //bobexample.setStatus('<img src="/css/i/openy.png" /> ', '<img src="/css/i/closy.png" /> ')
    bobexample.setColor('#ff6600', '#4d4d4d')
    bobexample.setPersist(false)
    bobexample.collapsePrevious(true) //Only one content open at any given time
    bobexample.defaultExpanded(0) // set first content to be expanded by default
    bobexample.init()
    DD Admin

  5. #5
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    oh my bad.. i just used "instance.defaultexpanded" instead of bobexample.defaultexpanded. it works perfect, thank you!

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
  •