Input elements in array


#1

Hi guys! I have this snippet:

<table>
  {{#each names as |name index|}}
    <tr>
      <th>{{input type="text" value=names.[index] placeholder=name}}</th>
    </tr>
  {{/each}}
</table>

Basically it should build a list of names using those input boxes. The array is already preallocated (I mean, those value are already set to something like Item 1Item N but I want the user to be able to overwrite it). Any idea why it’s not working?


#2

I’m not able to follow your question, but is this what you are trying to achieve? http://jsbin.com/jomemohage/1/edit?html,js,output

If not, edit it and reply.


#3

Yup, but what was not working is that updates in the inputs were not reflect in the labels below.

Thanks to guys in Ember Slack Community they made me notice strings could not be handled by Ember because they’re primitive and passed by value rather than by reference.

So, I changed my names to objects with a single property and it works now. I updated the JSBin so you can take a look.

Thanks for your help!