mercredi 11 février 2015

Ember reverseObjects not working right


I'm using Ember's reverseObjects() method, but it's not working as expected.


I have a text input and a submit button. Without the reverseObjects method all items are added to the list sequentially, as expected. When type in new items it gets weird. For example, typing the numbers 1 through 9 where each number is an entry should show a list like this:


9 8 7 6 5 4 3 2 1


What I get when I use reverseObjects is:


9 7 5 3 1 2 4 6 8


What's going on here and how do I fix it?


here's my js:


Thanks!



var userList = [];

App.AddItemsController = Ember.ObjectController.extend({
actions: {
// item entry form submit
inputSubmit: function(){
var value = this.get('itemName'); // gets text input value
userList.pushObject({
name: value
}).reverseObjects();
document.querySelector('.js-input-add-item').value = ''; // clear input on submit
return userList;
}
}
});




Aucun commentaire:

Enregistrer un commentaire