dimanche 14 février 2016

Each loop isn't returning the correct element when calling an action

I'm currently using Ember 1.13.7 and have hit an issue that I haven't seen in Ember before.

I have a route returning an array for the model. In my template I am then using an

{{#each model as |row|}} 

to loop through the returned items. There is a button associated with each row allowing a user to delete that row.

The data is being returned for each individual row correctly however if I click the button that then fires the action it is only receiving the id for the first row in the array. eg:

ID   Name      Action
1    Row 1     {{action 'delete' row}}
2    Row 2     {{action 'delete' row}}
3    Row 3     {{action 'delete' row}}

When I click on the delete button for Row 3 and write the id to console it is 1 whereas I'm expecting it to be 3.

The weird thing is I'm doing the exact same thing in another template and that works as expected so I'm unsure why it is happening in this situation.




Aucun commentaire:

Enregistrer un commentaire