Skip to content

Commit

Permalink
Updating documentation to take event proxying into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Hunter committed Feb 6, 2014
1 parent fa79fc4 commit 38b7604
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions doc/base_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Defaults to the component instance's `node` value.

The event type to listen for.

#### `handler`: Function | Object
#### `handler`: Function | Object | String

Either a function (callback) to be invoked, or a map of targets and callbacks.
Either a function (callback) to be invoked, a map of targets and callbacks, or a string (event name) to be triggered.

Example of `handler` being a function:

Expand Down Expand Up @@ -129,6 +129,29 @@ this.after('initialize', function() {
});
```

Example of `handler` being a string that maps events to other events.
This is useful for proxying browser events to more meaningful custom events.

```js
this.on('click', 'uiComponentClick');
```

Example of `handler` being an object that maps events to other events.

```js
this.defaultAttrs({
menuItemSelector: '.menuItem',
saveButtonSelector: '#save'
});

this.after('initialize', function() {
this.on('click', {
menuItemSelector: 'uiMenuItemClick',
saveButtonSelector: 'uiSaveButtonClick'
});
});
```

<a name="this.off"></a>
## this.off([selector,] eventType [, handler])

Expand Down

0 comments on commit 38b7604

Please sign in to comment.