- Hey Jack -
When a menu is hidden, its selection is cleared. So, when the menu is
clicked you'll have to store a reference to the selected item and then
use the "parent" property to crawl up and show each parent menu. That
said, why are you doing this? What is the use case here? This
interaction you are trying to create doesn't make sense to me. I have
never used an application where a button's flyout menu appears pre-
expanded with the selected item shown.
Jack Bates wrote:
> Awesome, thanks Todd, that works.
> Now, when I show the menu, and the selected menu item is nested in a
> submenu, I need to expand it's parent submenus, so the user can find the
> selected menu item.
> I tried to achieve this using the following:
> button.getMenu().subscribe('show', function (type, args)
> if (button.get('selectedMenuItem') != null)
> I select a menu item in a submenu, "BBB". When I subsequently show the
> menu, I expect the submenu containing "BBB" - the "AAA" submenu - to be
> Instead however, only the root menu is shown.
> How do I expand nested submenus to show the selected menu item when the
> menu is shown?
> Thanks again, Jack
>> Jack -
>> The MenuItem that was the target of the click event will be sent back
>> the arguments array that is passed back to your handler. This is
>> covered in this section of the Menu landing page:
>> - Todd
>> Jack Bates wrote:
>>> When a sub menu item is clicked, how can I get that menu item?
>>> I applied a "click" event handler to a menu button in order to
>>> the button label when a menu item is selected:
>>> button.getMenu().subscribe('click', function (event)
>>> It works for simple menu items, but not for sub menu items:
>>> In this test case, selecting either "AAA" or "CCC" will correctly
>>> the button label. However selecting the "BBB" sub menu item
>>> changes the button label to "AAA"
>>> How can I get the sub menu item which was clicked, so I can set the
>>> button label to "BBB" when "BBB" is selected?
>>> Thanks and best wishes, Jack