Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to allow only one fold to be open at a time #6

Closed
blimpmason opened this issue Nov 12, 2016 · 3 comments
Closed

Option to allow only one fold to be open at a time #6

blimpmason opened this issue Nov 12, 2016 · 3 comments

Comments

@blimpmason
Copy link

Is there a method I could use on the onToggle callback to collapse all other folds when one is expanded? So if you open one, any open section collapses.

@Alhadis
Copy link
Owner

Alhadis commented Nov 12, 2016

Hey buddy,

Not out-of-the-box, I'm afraid. Try using this as your onToggle callback:

onToggle: function(target){
    target.accordion.folds.forEach(fold => {
        if(fold !== target)
            fold.open = false;
    });
}

I thought to include a modal option, but wanted the core code to be as minimal as possible. Though I should probably make a note of this snippet in the readme, since modal accordions are that common. =)

@blimpmason
Copy link
Author

Perfect, thanks! Much appreciated.

@Alhadis
Copy link
Owner

Alhadis commented Nov 12, 2016

No problem! Glad I could help. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants