Skip Navigation

[Resolved] Set Accordion Default to Closed

This thread is resolved. Here is a description of the problem and solution.

Problem:
I would like Accordion tab in a layout. to be collapsed by default.

Solution:
You would need to remove the class "in" from the panel.

Go to: Toolset > Layouts CSS & JS, in the JavaScript editor you should be able to add the following to strip the 'in' class when the page loads. In this case it would be for any panels, but you have only one. If you had multiple panels you would need a more specific selector.

( function( $ ) {
    $( document ).ready( function(){
        $('.panel-collapse').removeClass('in');
        $('.panel-title > a').addClass('collapsed');
    });
})( jQuery );
This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by markH-16 7 years, 1 month ago.

Assisted by: Noman.

Author
Posts
#575247

I added an Accordion to a Layout. I'm only using one panel and I would like it to be collapsed by default. Is there a way to set the panel to 'collapsed', rather than 'open'.

My Panel title is; "How this page was made." The idea is, I'm new to Toolset and I want to document how I do things, so I don't forget. This is my test site, so to speak. You can see it at the bottom of this page: hidden link

Or, can I use Access to display this bit of content only to certain roles? I'd want others to see the rest of the page, but only certain roles to see the instructions.

Thanks.

#575282

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi mark,

Thank you for contacting Toolset support.

1. Accordion to be collapsed by default, what you need to do is to remove the class "in" from the panel.

Go to: Toolset > Layouts CSS & JS, in the JavaScript editor you should be able to add the following to strip the 'in' class when the page loads. In this case it would be for any panels, but you have only one. If you had multiple panels you would need a more specific selector.

( function( $ ) {
    $( document ).ready( function(){
        $('.panel-collapse').removeClass('in');
        $('.panel-title > a').addClass('collapsed');
    });
})( jQuery );

2. For limiting read access to specific content, please use Access plugin and follow this doc:
https://toolset.com/documentation/user-guides/limiting-read-access-specific-content/

Download Access plugin form here:
https://toolset.com/download/toolset-access/

Thank you

#575336

Thanks Noman. I added the js. That works perfectly.