Skip to content

Commit 1d5b4c7

Browse files
committed
Added callback sample to demo
1 parent 193dc4d commit 1d5b4c7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ $("#container").contextmenu({
5757

5858

5959
Instead of handling all menu commands in the `select` event, it is also possible
60-
to attach callbacks to single menu entries using the `action` property:
60+
to attach callbacks directly to menu entries:
6161
```js
6262
$(document).contextmenu({
6363
delegate: ".hasmenu",
6464
menu: [
65-
{title: "Copy", cmd: "copy", uiIcon: "ui-icon-copy", action: function(event, ui){
65+
{title: "Copy", uiIcon: "ui-icon-copy", action: function(event, ui){
6666
alert("Copy " + ui.target.text());
6767
}
6868
},

demo/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
font-size: .8em;
4949
}
5050
.ui-menu {
51-
width: 120px;
51+
width: 150px;
5252
}
5353

5454
/* Define a custom icon */
@@ -75,7 +75,7 @@
7575
{title: "Paste", cmd: "paste", uiIcon: "ui-icon-clipboard", disabled: true },
7676
{title: "----"},
7777
{title: "More", children: [
78-
{title: "Sub 1", cmd: "sub1"},
78+
{title: "Sub 1 (using callback)", action: function(event, ui) { alert("action callback sub1");} },
7979
{title: "Sub 2", cmd: "sub1"}
8080
]}
8181
],
@@ -162,6 +162,7 @@ <h1>jquery.ui-contextmenu.js</h1>
162162
<h3>Sample 1</h3>
163163
<ul>
164164
<li>Initialized using a command-array.
165+
<li>Entry 'More - Sub1' uses the callback syntax.
165166
<li>The menu is modified in the `beforeOpen` event (disabling an renaming entries).
166167
<li>`preventSelect: true` prevents accidential selection of the menu
167168
targets (i.e. 'AAA') when double-clicking or dragging the mouse.

0 commit comments

Comments
 (0)