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 labelString | Object Can also be the opts object, containing a label and command entry, doubles as ID
commandfunction Callback function
optsObject Options
Properties
Name Type Argument Description idstring Identifier
labelstring The menu label
commandfunction | string <optional>
Command name or function to call when invoked
classListstring <optional>
CSS classes to add
contextarray An array of context entries
Properties
Name Type Argument Description selectstring the CSS query for the parent
beforestring <optional>
the CSS query for the left sibling (use either before or after, not both)
afterstring <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 idString Identifier
optsObject Provide the context that was used to register {context: ..}