mikeric / rivets

Lightweight and powerful data binding.

Home Page:http://rivetsjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event handling

toby1kenobi opened this issue · comments

Rivets looks really useful, but I'm struggling with the documentation. If I use rv-each-* to output a list of items, and I want something in each to be click-able, is there are rivet-y way of hooking these up or should I just use jQuery or something?

I can see here a reference to augmenting 'the event handler of the on-* binder', which sounds hopeful, that seems to be the only reference to it though.

Hi, sorry for the delay. This is exactly the kind of thing rivets is for. You simply use the on-* binder, as referenced here. So your html might look like (where items is an array and openItem is a function):

<ul>
  <li rv-each-item="items" rv-on-click="openItem"></li>
</ul>

Does that help at all?

Thanks, that looks great - not sure how I'd missed it!

Cool, closing this, feel free to open another issue if you have any other problems!