Work with Menu
Hiding/showing menu options
You can hide and show menu items (one or several at once) with the help of the hide() / show() methods:
menu.hide(id);
menu.show(id);
Related sample: Menu. Show / hide menu item
Both methods can take one parameter - the ID of a menu item or an array with IDs of menu items.
Starting from v7.0, it is possible to hide/show all Menu items on the page at once by using the methods without parameters:
// hides all Menu items
menu.hide();
// shows all Menu items
menu.show();
Disabling/enabling menu options
You can disable one menu option or several options at a time with the disable() method:
menu.disable("1");
menu.disable(["2","3"]);
To enable one menu option or several options at a time, use the enable() method:
menu.enable("1");
menu.enable(["1","3"]);
Related sample: Menu. Enable / disable menu item
Both methods can take one parameter: the ID of a menu item or an array of IDs.
Starting from v7.0, it is possible to disable/enable all Menu items on the page at once by using the methods without parameters:
// disables all Menu items
menu.disable();
// enables all Menu items
menu.enable();
Checking if a menu option is disabled
To check if an item of Menu is disabled, call the isDisabled() method. The method takes one parameter:
id | (string, number) an id of a menu item |
menu.isDisabled("1"); // -> true/false
Related sample: Menu. Enable / disable menu item
Selecting/Unselecting an item
Selecting a menu item
To select a particular Menu item, make use of the select() method of Menu. The method takes two parameters:
id | (string, number) an id of an item |
unselect | (boolean) optional, true - to unselect previously selected items, otherwise - false; true by default |
menu.select("align-left");
Related sample: Menu. Select / unselect
Unselecting a menu item
To remove selection from a selected item, apply the unselect() method of Menu. The method may take the id of an item as a parameter:
// unselects a specified selected item
menu.unselect("align-left");
It is also possible to remove selection from all previously selected items of Menu via the unselect() method:
// unselects all previously selected items
menu.unselect();
Related sample: Menu. Select / unselect
Checking if a menu item is selected
To check if an item of Menu is selected, call the isSelected() method. The method takes one parameter:
id | (string, number) an id of a menu item |
menu.isSelected("align-left"); // -> returns true/false
Related sample: Menu. Select / unselect
Getting selected items
To get the selected items, call the getSelected() method. The method returns an array of string values with IDs of selected items:
menu.getSelected(); // -> ["selected_1", "selected_1.1"]