Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery accordion collapsed by default on page load

I am using JQuery UI accordion in my page. I have following Javascript code on my page load:

$(function() {
    $("#accordion").accordion({
            active: false,
            autoHeight: false,
            navigation: true,
            collapsible: true
        });

});

When the page loads all tabs are open for few seconds and then collapse. May be its loading effect. How can I make Jquery UI accordion collapsed on page load. Please suggest

like image 286
DotnetSparrow Avatar asked Jul 04 '11 20:07

DotnetSparrow


People also ask

How do I set my accordion to open by default?

To create an accordion that is collapsed by default, we need to set the 'active' property of the jQuery Accordion as false.

How to collapse accordion in jQuery?

collapse', function () { $('#accordion . in'). collapse('hide'); });

How do I make accordion open by default in bootstrap?

If you'd like it to default open, add the additional class show . To add accordion-like group management to a collapsible area, add the data attribute data-parent="#selector" . Refer to the demo to see this in action.


2 Answers

Although not a direct answer, maybe you can render it hidden and then show it when its created:

$("#accordion").accordion({
   active: false,            
   autoHeight: false,            
   navigation: true,            
   collapsible: true,
   create: function(event, ui) { $("#accordion").show(); }
});

Update: This fiddle works for me: http://jsfiddle.net/47aSC/6/

like image 115
Mrchief Avatar answered Oct 04 '22 00:10

Mrchief


For me this works:

$(function() {
    $( "#accordion" ).accordion({
            collapsible: true,
            autoHeight: true,
            active: false

        });
});
like image 34
mat0r Avatar answered Oct 04 '22 00:10

mat0r