knockout.contextmenu
Contextual menu, anywhere you need it
Install
npm install knockout.contextmenu --save bower install knockout.contextmenu
npm
With Just do:
;
Usage
To bind a context menu to an element:
Dont forget to include the .css
file.
You can also bind a boolean observable to the context menu, that will work as a 'check':
"Boolean": someObservableBoolean "One method": $roottest
You can also set dynamic 'text' and 'visible' values binding an object with the following values instead of a method:
Option | Description |
---|---|
url |
Direct access to an URL. |
text |
Set menu text. |
visible |
Show/hide item (result must be boolean). |
action |
Item method, mandatory if not url defined. |
disabled |
Disable menu item. |
Example:
"Complex item": "text": $root "visible": == '1' "action": $rootsomeAction "One method": $roottest
To create a separator between two menus, just create an object with the property separator
with true
:
"Some item": methodOne "Separator": "separator": true "visible": "Just another item": methodTwo
Bind it with left click, if you want to:
Also supports observableArrays
!
var menu = ko;
License
MIT