Closed schellenbergk closed 6 years ago
:wave: Hey mate,
Yes, just add the open
class to the first fold before creating the Accordion
instance.
To collapse other elements when expanding a new one, add this to your Accordion
's instance:
onToggle: function(target){
target.accordion.folds.forEach(fold => {
if(fold !== target)
old.open = false;
});
}
thanks!!, just correct that mistake old.open = false;
;)
@schellenbergk I'm glad I could help. Since you're not the first person to ask about this, I think I will make this a core option after all. Looking back, my decision to optimise space by omitting a modal
option really doesn't justify the added effort required of authors.
Expect a new release in the near future that will allow you to implement the above behaviour simply by passing modal: true
as an option. =)
Is there an easy way to keep first item expanded by default. Also when expanding a new element collapse the previous one? Thanks.