Can't you use a similar approach? Define an index in the repeat. On Dec 14, 2014 4:08 AM, <[email protected]> wrote:
> Eric, > > One further question, > How do you get the parent template index. To remove Phones from the > Contact I need the Contact index, from your example I can get the current > template (Phones) index but I also need the containing parent (Contacts) > index > > See http://jsbin.com/yubigo/5/edit?html,output, look at the removePhone > function. > > In the debugger I can see the parent model it looks to be an > auto-generated id, with no easy way to access? > > > <https://lh3.googleusercontent.com/-SrwfOkfgWRg/VI19L02OgwI/AAAAAAAAABA/f-yBZMdRfHI/s1600/SqlDesignerPolymer_-_%5BFDataDevelopmentHtml5_Pr_2014-12-14_07-04-41.jpg> > > Thanks, > Dan > > > On Sunday, December 14, 2014 1:49:12 AM UTC-5, [email protected] wrote: >> >> I am trying to convert Knockout contacts example to Polymer just for >> reference and was wondering if there is an easier method to get the >> selected index of a row. >> >> Here is the Knockout example I am converting http://jsfiddle. >> net/rniemeyer/gZC5k/ >> >> Here is what I am working on http://jsbin.com/yubigo/2/edit?html,output >> <http://www.google.com/url?q=http%3A%2F%2Fjsbin.com%2Fyubigo%2F2%2Fedit%3Fhtml%2Coutput&sa=D&sntz=1&usg=AFQjCNEvONmEDi8-pE8pik7-Ze3P1HyUrw> >> >> I know I can find the index by using something like this, this would be >> for deleting a contact >> >> 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/61fb2ef2-ad0e-42d5-94f3-f17946485dec%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/61fb2ef2-ad0e-42d5-94f3-f17946485dec%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CACGqRCAeTiYgC9fPaV8mf-gP7HsdDvEJNd5Tn8%3DEoNqXCD%3DKdg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
