backbone.jsbackbone-views

Delegating events


I've got a backbone view for an entire collection (a list of "clickable" categories). Can I delegate events on each item of the view so that I can find which category has been clicked?


Solution

  • Here's a post that might help. Basically you use a data-* attribute in the item view to store and then retrieve the id of item clicked:

    If you'd rather go directly to code, here's the jsFiddle that's used in the post to demonstrate. Hope that helps.