adobe-accessibility / Accessible-Mega-Menu

A demonstration of how to implement a keyboard and screen reader accessible mega menu as a jQuery plugin.
Apache License 2.0
605 stars 199 forks source link

Multiple instances of the menu #3

Closed skifte closed 11 years ago

skifte commented 11 years ago

If you initialize two or more instances of the accessible mega menu in the same page it gets all messed up.

The problem seems to be the menu variable inside _togglePanel. The context of this variable is always set to the last instance of the accessible mega menu, so it have to be reset.

This seems to do the trick (inside _togglePanel()):

menu = $(event.target).closest('.' + settings.menuClass); // correct context

skifte commented 11 years ago

It seems like the problem may be an error in the merging of options and defaults into settings, or something.

When I have multiple instances of the menu, on the same page, the last instance's options/settings are used for all.

majornista commented 11 years ago

Hi Anders,

Thanks for your feedback. I've committed a fix which should clarify the scope within private methods, which should allow you to instantiate more than one mega menu with different className settings on a page.

See 71bfe6f2655311b9a6c18c876a0ff7de1a94c4da and bb1eb353eabd734010714a938e09757675a39109

Cheers, Michael