removeContact: function(e, detail, sender){var obj = e.target.templateInstance.model.row;
var found_index = this.data.indexOf(obj);
if (found_index !== -1) {
this.data.splice(found_index,1);
}
}
Or if I want to pass the index from the template I can do something like using the polymer index syntax and assigning it to a html5 data attribute such as data-idx
<template repeat='{{c,idx in data}}'><tr>
<td>
<input value='{{idx}}' />
<input value='{{c.firstName}}' />
<div><a href='javascript:;' on-tap='{{removeContact}}' data-idx='{{idx}}'>Delete</a></div>
</td>
<td><input value='{{c.lastName}}' /></td>
</tr>
</template>But having to add the polymer index syntax and data- attribute or having to search for the index in js each time is a little bit of a pain especially since Polymer already has the index for the selected row.Is the selected index exposed in js somewhere that I am missing?
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/39434bd7-5269-44cc-902e-06517a081c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Can't you use a similar approach? Define an index in the repeat.
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/61fb2ef2-ad0e-42d5-94f3-f17946485dec%40googlegroups.com.
removePhone: function(e, detail, sender){
var contactIdx = parseInt(sender.templateInstance.model.c.idx)
var phoneIdx = parseInt(sender.templateInstance.model.idx)
this.data[contactIdx].splice(phoneidx,1);
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/d95ef006-ead5-49d6-8175-f78fc543d9b8%40googlegroups.com.