Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foundation – Deep linking to accordion tab?

Am I able to deep link to a tab inside Accordion?

For example, let's say I am clicking a link such as http://domain.com/page#tab-23 from an external source – how can I make tab 23 active/opened when the page is loaded?

There is a deep_linking option for Tabs, but not for Accordion.

Thanks.

like image 693
Vlasta Novak Avatar asked Oct 20 '22 02:10

Vlasta Novak


1 Answers

It's not the most elegant but you could look for a hash in the URL and trigger a click on the corresponding accordion element.

JS

if(window.location.hash) {
  var hash = window.location.hash;
  $('.accordion a[href="' + hash + '"]').trigger('click');
}

Here's a working demo.

like image 129
Brett DeWoody Avatar answered Oct 31 '22 10:10

Brett DeWoody