Hacker News new | past | comments | ask | show | jobs | submit login

RE the event signature: (If you raise an event from an item within a repeated block then synergy provides the data for that item as the second argument to your event handler function.) If you have a nested loop then you'll get the data item for that particular loop.



Right, sorry I think I wasn't clear. I'm wondering how one goes about something like this

    as.map(a =>
      <tr>{
        bs.map(b => <td onClick={() => foo(a, b)}></td>)
      }</tr>
    )
Notice how both `a` and `b` are passed into `foo`. There are other possible permutations, such as passing indices or properties of items. I believe it's possible to access `b.bar` easily enough, but it wasn't clear how to access `a` or the index of `as.map` from inside the inner loop.


see the comment above "RE: #" concerning the index. synergy doesn't provide means for you to pass custom arguments into the event handlers, but the event target and the datum provide context of the loop and the handlers "this" is the viewmodel itself.


So then one would do `function foo(e, b, a) {...}` to access `a`?


Apologies for the late reply, finally I had to get some sleep! No, you only get the datum for the loop from which the event is raised.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: