Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding some info about event callbacks #674

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/docs/reference/_binders/on-[event].md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,40 @@ Binds an event listener on the element using the event specified in `[event]` an
```html
<button rv-on-click="item.destroy">Remove</button>
```

*The callback function is passed 1: an event object and 2: the bound context which will also include named refrences to nested bindings.*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: references


```html
<ul>
<li rv-each-a="view.a">
<ul>
<li rv-each-b="a.b">
<button rv-on-click="view.clicked">third</button>
<li>
</ul>
<li>
</ul>
```

```javascript
view = {
a: [ { b:[ { "..." } ] } ],
clicked: function(e, bound){
console.log(bound);
}
}

rivets.bind(el, {view: view});
```

```
//console output:
{
view: {...},
b: {...},
a: {...},
index:n
}
```

*Also note that the arguments passed to the event callback can be [reconfigured](/docs/guide/#usage-configuring) through the `handler` property.*