Is it possible to set all accordions opened by default?

3 replies · opened May 14, 2019

Jjavck2May 14, 2019

Hello,

I know how to set all accordion items closed by default.

In contrast, is it possible to let them opened by default?

Thanks~

SSemicolon WebSTAFFMay 14, 2019

Hello,

This is Definitely Possible, however, minor JS Customizations are required for this. Find the following code in the js/functions.js File:

if( $(this).next().is(':hidden') ) {
	element.find('.acctitle').removeClass('acctitlec').next().slideUp("normal");
	var clickTarget = $(this);
	$(this).toggleClass('acctitlec').next().stop().slideDown("normal", function(){
		if( ( $body.hasClass('device-sm') || $body.hasClass('device-xs') ) && element.hasClass('scroll-on-open') ) {
			$('html,body').stop(true).animate({
				'scrollTop': clickTarget.offset().top - ( SEMICOLON.initialize.topScrollOffset() - 40 )
			}, 800, 'easeOutQuad' );
		}
	});
}

and replace it with:

element.find('.acctitle').removeClass('acctitlec').next().slideUp("normal");
var clickTarget = $(this);
$(this).toggleClass('acctitlec').next().stop().slideDown("normal", function(){
	if( ( $body.hasClass('device-sm') || $body.hasClass('device-xs') ) && element.hasClass('scroll-on-open') ) {
		$('html,body').stop(true).animate({
			'scrollTop': clickTarget.offset().top - ( SEMICOLON.initialize.topScrollOffset() - 40 )
		}, 800, 'easeOutQuad' );
	}
});

and then add the following code at the bottom of your HTML File after the js/functions.js JS File Linking:


	jQuery(document).ready( function(){
		jQuery('.accordion').find('.acc_content').show();
	});

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Jjavck2May 15, 2019

Hello,

it works, thank~

But if I wish that only open some accordions but not all.
Do I have any strategy to do that? Ex. properties

Best Regards~

SSemicolon WebSTAFFMay 15, 2019

Hello,

Unfortunately, this is not supported out of the box at the moment and will require customization.

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard