views:

257

answers:

2

How do I default an accordion to be closed on start-up. here is the sample view here

Here is the code:

<script>
$(function() { 

$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide'});
});
</script>

<script>

// add new effect to the tabs
$.tools.tabs.addEffect("slide", function(i, done) {

    // 1. upon hiding, the active pane has a ruby background color
    this.getPanes().slideUp("slow").css({backgroundColor: "#fff"});

    // 2. after a pane is revealed, its background is set to its original color (transparent)
    this.getPanes().eq(i).slideDown("slow", function()  {
        $(this).css({backgroundColor: 'transparent'});

        // the supplied callback must be called after the effect has finished its job
        done.call();
    });
});
</script>
A: 

put in your css:

#accordion div.pane: display:none;
XGreen
didn't work as well....
kwek-kwek
A: 

You can do it like this:

$("#accordion")
  .tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', collapsible: true})
  .tabs('select', false);

This marks it as collapsible, then selects a tab that's not there to display, using false.

Nick Craver
doesn't work$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', accordion: true}).tabs('select', false);;});
kwek-kwek
doesn't work$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', accordion: true}).tabs('select', false);;});
kwek-kwek
@kwek-kwek you're missing the collapsible: true in the options on both of those :) scroll right in my answer to see what I mean
Nick Craver
Ok my bad heheh here is that I have now <script>$(function() { $("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', collapsible: true}).tabs('select', false);;});</script> still not working
kwek-kwek