I am working on Polymer and pretty new in this.
I have a list which iterates using a template. There needs to be a remove button on that. On click of remove I am calling a function. How do we know which list item was called so that I can have the item to remove.
<template repeat="{{ data in listData }}">
<div>
<img src="../../Styles/images/edit.png" alt="">
<img src="../../Styles/images/remove.png" alt="">
</div>
</template>
I was doing the remove like this before
<img src="../../Styles/images/remove.png" alt="" id="data.id" on-click={{remove}}"">
So, on remove function I get the Id using the event parameter in the function handler. Now, I have this edit as well. So, now in the same approach, i will have an id for the edit as below.
<img src="../../Styles/images/edit.png" alt="" id="data.id" on-click={{remove}}"">
Since both ids cannot be same, I can append some text also along with the id to make it different. However I am not in favour of this approach. Can anyone throw some light on how to respond to events within a repeat template so that we can know which item was called for.
Thanks, Sumesh