diff --git a/documentation/_data/nav.js b/documentation/_data/nav.js index 8d7db221..07ee3024 100644 --- a/documentation/_data/nav.js +++ b/documentation/_data/nav.js @@ -47,6 +47,7 @@ module.exports = [ { id: 'html5-polyfill', text: 'HTML5 polyfill', url: '/demo/html5-polyfill.html' }, { id: 'html5-polyfill-firefox8', text: 'HTML5 polyfill (Firefox)', url: '/demo/html5-polyfill-firefox8.html' }, { id: 'input', text: 'Input Commands', url: '/demo/input.html' }, + { id: 'input-rename-trigger', text: 'Input Commands (accessing the trigger)', url: '/demo/input-rename-trigger.html' }, { id: 'keeping-contextmenu-open', text: 'Keeping the context menu open', url: '/demo/keeping-contextmenu-open.html' }, { id: 'menu-title', text: 'Menus with titles', url: '/demo/menu-title.html' }, { id: 'menu-promise', text: 'Menu with promise', url: '/demo/menu-promise.html' }, diff --git a/documentation/demo/input-rename-trigger.md b/documentation/demo/input-rename-trigger.md new file mode 100644 index 00000000..1db4babb --- /dev/null +++ b/documentation/demo/input-rename-trigger.md @@ -0,0 +1,63 @@ +--- +currentMenu: input-rename-trigger +--- + +# Demo: Renaming the trigger from an input command + + + + + +- [Example code](#example-code) +- [Example HTML](#example-html) + + + +Item level [`events`](../docs/items.html#events) handlers are bound with the menu's +options object as jQuery event data, so `e.data.$trigger` is the element that opened +the menu. Inside the handler `this` is the `` itself, exactly like any other +jQuery event handler. + +Both buttons below share a single menu definition. Left-click one, type a new label +and click somewhere else so the input loses focus. The button you clicked is renamed, +the other one is not. + + + + +## Example code + + + +## Example HTML +
diff --git a/documentation/docs/items.md b/documentation/docs/items.md index 2b49cca8..7f903a93 100644 --- a/documentation/docs/items.md +++ b/documentation/docs/items.md @@ -316,12 +316,20 @@ __Only used with [types](#type) `text`, `textarea`, `radio`, `checkbox` and `sel `events`: `object` +Inside a handler: + +* `this` is the ``, `