JQUERY UI Accordion start collapsed
Asked Answered
D

7

84

How can I make the jquery UI accordion start collapsed when the form loads. Is there any javascript code for this?

Drover answered 30/10, 2011 at 21:1 Comment(0)
W
204

In your options specify:

{
  ...
  active: false,
  collapsible: true,
  ...
}

See documentation for active.

Warmongering answered 30/10, 2011 at 21:7 Comment(3)
still working on JQuery 1.4.4 as of today, though Visual Studio 2010 throws a JScript error (no error in the UI) on IE 8Eyestalk
It still shows the accordion collapsing though, any way to speed that up at initial collapsing or prevent this? animate: false gets rid of the animation but for always, ideally only remove it for initial load.Cycad
UPDATE: Please disregard, I had .accordion wrapped in $( function() { } ); , without that it works just fine and without animation at initial load, nice.Cycad
R
9

I was trying to do the same thing. Using Jquery UI tabs. I wanted none to show with 5 tabs when you start.

using active: false showed the 5th tabs content. So I set tabs CSS to display:none; since it in-line changes display. Hope this helps someone!

<script>
$(function() {
    $( "#tabs" ).tabs({
        active: false,
        collapsible: true,
    });
});

And in the style

#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5{ 
    display:none;
}
Ryals answered 9/11, 2012 at 15:16 Comment(0)
A
4

I used this code, as i was using a Dreamweaver Widget, the code that Topek didnt work for me hope this helps,

jQuery("#jQueryUIAccordion").accordion({ 
        event: "click",
        active: false,
        collapsible: true,
        autoHeight: false

    });
Astraphobia answered 3/3, 2013 at 23:5 Comment(0)
C
3

To complete the answer of topex, With Jquery UI 1.10.3 I had to set the 'collapsible' option before the 'active' one.

$( ".accordion" ).accordion("option", { 
    collapsible: true,
    active: false
});

See the documentation

Cryptic answered 28/6, 2013 at 7:56 Comment(2)
It still shows the accordion collapsing though, any way to speed that up at initial collapsing or prevent this? animate: false gets rid of the animation but for always, ideally only remove it for initial load.Cycad
UPDATE: Please disregard, I had .accordion wrapped in $( function() { } ); , without that it works just fine and without animation at initial load, nice.Cycad
I
1

If you're using the wysiwyg "Properties" and the coding confuses, try putting a number in the "Active" box one more than your list of Sections. I have 12 sections and put "13" in there and it worked for me.

Individually answered 6/3, 2014 at 22:18 Comment(0)
A
1

If you are using default jquery accordion it always display first panel content, you can disable it by using active: false attribute.

jQuery(document).ready(function() {
    jQuery( "#accordion" ).accordion({
      collapsible: true,
      active: false,
    });
});

but it's default behavior is for all panels will be set to the height of the tallest panel. so, for that you have to add "heightStyle" attribute.

heightStyle: "content",

so, each panel will be only as tall as its content.

Assignor answered 25/12, 2017 at 6:16 Comment(2)
It still shows the accordion collapsing though, any way to speed that up at initial collapsing or prevent this? animate: false gets rid of the animation but for always, ideally only remove it for initial load.Cycad
UPDATE: Please disregard, I had .accordion wrapped in $( function() { } ); , without that it works just fine and without animation at initial load, nice.Cycad
M
0

If you look at the beginning of the panel group in your code, look for this

<div id="collapseOne1" class="panel-collapse collapse in"> 

if you just remove the "in" it has the panel close when the page loads.

Misrule answered 21/4, 2016 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.