Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Mobile Menu Accordion Menu - Expand "active" submenu parent automatically #822

Closed
photonomad opened this issue May 19, 2016 · 5 comments
Closed

Comments

@photonomad
Copy link

Is there a way to make menu-items with the "active" and "is-accordion-submenu-parent" classes automatically be expanded when the page loads?

It would be more convenient for viewers if the active menu item in the vertical accordion menu would just be open by default, but I can't figure out where or how to edit the code to make this happen.

Thanks in advance for any suggestions!

@AdamChlan
Copy link
Contributor

See if this helps you out:

http://foundation.zurb.com/forum/posts/21440-accordion-expand-all-on-load http://foundation.zurb.com/forum/posts/21440-accordion-expand-all-on-load

On May 19, 2016, at 3:56 PM, photonomad [email protected] wrote:

Is there a way to make menu-items with the "active" and "is-accordion-submenu-parent" classes automatically be expanded when the page loads?

It would be more convenient for viewers if the active menu item in the vertical accordion menu would just be open by default, but I can't figure out where or how to edit the code to make this happen.

Thanks in advance for any suggestions!


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub #822

@photonomad
Copy link
Author

Thanks @AdamChlan - though, I think the solution in that thread is not compatible with Foundation 6.

This is the solution I found that works with the Foundation 6 Accordion Menu:

$(window).load(function() {
$(".active a").trigger('click');
});

@thomasfrobieter
Copy link

thomasfrobieter commented Jan 24, 2018

"To have a sub-menu already open when the page loads, add the class .is-active to that sub-menu."
(Hint: You have to set it on the UL)

@santiagoarizti
Copy link

@thomasfrobieter thank you, I was setting it to the

  • element where the sumenu was in.

  • @AlexLaforge
    Copy link

    If you need to do it manually, you can use this code (tested with Foundation 6.4.3) :
    $('.menu.vertical.accordion-menu[data-accordion-menu] .is-submenu-item.is-accordion-submenu-item > a.current').parents().find('.is-accordion-submenu-parent > a').trigger('click');

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

    No branches or pull requests

    5 participants