addItem (value)
value. Main menu item, an instance of the MainMenuButton class.
The addItem method adds a child component of the main menu.
To execute the example, the HTML page must contain MainMenu component named mainMenu (see Example of Creating the MainMenu Component). Add the input box, in which the name of the menu item is set, to the page, and the button by clicking which the item with the selected name is added to the main menu:
<input type="text" id="addCont" />
<input type="button" id="addBut" value="Add item" onclick="AddItem();" />
The following javascript code must be added to the separator:
function AddItem() {
var addCont = document.getElementById("addCont");
var item = new PP.Ui.MainMenuButton();
item.setContent(addCont.value);
mainMenu.addItem(item);
}
The item with the name is added to specified in the input box by clicking which the input box and the Add Item button are allocated on the HTML page after an example execution:
See also: