The menu SDK allows you to easily register new menu items
Example
var opts = { label:"Hello!", // mandatory, the rest are optional image:"", command: () => alert("Hello!"), classList:"", context: [ { select: "#popup_view", before: "#menu_view_tabs" } ] }; require("ko/menu").register(opts);
- Copyright:
-
- (c) 2017 ActiveState Software Inc.
- License:
-
- Mozilla Public License v. 2.0
Methods
-
require("ko/menu").register(label, command, opts)
-
Register a new menu item
Parameters:
Name Type Description label
String | Object Can also be the opts object, containing a label and command entry, doubles as ID
command
function Callback function
opts
Object Options
Properties
Name Type Argument Description id
string Identifier
label
string The menu label
command
function | string <optional>
Command name or function to call when invoked
classList
string <optional>
CSS classes to add
context
array An array of context entries
Properties
Name Type Argument Description select
string the CSS query for the parent
before
string <optional>
the CSS query for the left sibling (use either before or after, not both)
after
string <optional>
the CSS query for the right sibling (use either before or after, not both)
-
require("ko/menu").unregister(id, opts)
-
Unregister a menu item
Parameters:
Name Type Description id
String Identifier
opts
Object Provide the context that was used to register {context: ..}