mardi 24 février 2015

Items are sorted differently when one them is saved?

I'm showing downloads of my post. Upon clicking on them an action is executed to increment their download-count and issue the download itself.


When there are two download-items, I click on the first one, its download-count changes in the templates and it switches position with the second download-item. Why are they interchanged and how can I prevent it?


This is the template:



{{#each download in post.downloads }}
<p>
<a {{ action "incDownload" download }}>
{{ download.name }}
</a> - {{ unbound download.downloadcount }} Hits
</p>
{{/each}}


This is the controller:



import Ember from 'ember';

export default Ember.ObjectController.extend({

actions: {
incDownload: function(obj) {
obj.incrementProperty('downloadcount')
obj.save()
}
}
}
})




Aucun commentaire:

Enregistrer un commentaire