nico3333fr / jquery-accessible-accordion-aria

jQuery Accessible Accordion System, using ARIA
MIT License
60 stars 19 forks source link

Trigger accordion panels with a button/links (question) #22

Open blobula opened 7 years ago

blobula commented 7 years ago

capture Hello,

I'm currently implementing this accordion on a site and I was curious how I'd be able to use a bootstrap navbar containing links that would control the opening and closing of them instead of clicking on the panel itself.

I feel like it would be pretty simple but not sure how to integrate it into your js file.

I've attached a screenshot showing what I'm referring to.

I've also attached the following jquery i have written, but there are bugs in this. It takes two clicks to open the panel, and it also isn't dynamic as I've set the panel to open.

function expandPanelBar(title) { //accordion $("#" + title + " a").on('click', function (event) { $('#accordion #accordion-0_tab').focus().click(); $("html, body").animate({ scrollTop: $("#anchor_" + title + "").offset().top }, 1000); }); }

I feel like it would be great if somehow I could tap into the clickButtonEventHandler on line 113 for the panels.

Thanks!