PDA

View Full Version : switch content script



nicker
08-26-2012, 10:49 PM
Im having a problem with switch content script http://www.dynamicdrive.com/dynamicindex17/switchcontent.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?


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>

ddadmin
08-28-2012, 12:34 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

nicker
08-30-2012, 12:37 AM
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.

ddadmin
08-30-2012, 07:27 AM
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:


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()

nicker
08-31-2012, 02:27 AM
oh my bad.. i just used "instance.defaultexpanded" instead of bobexample.defaultexpanded. it works perfect, thank you!