Whenever I save data ( self.get('content').pushObject(record);) and push the record back into the content Array, the observable doesn't get fired. I need the observable to fire so the content array gets sorted again. Can you please explain to me why its not firing?
saveIdea.IndexController = Ember.ArrayController.extend({
appName: 'My First Example',
todaysDayOfMonth: moment().format('DD'),
todaysMonth: moment().format('MMMM'),
body: '',
taggy: '',
content : Em.A(),
sortContent : function()
{
var ideas = this.get('content').toArray();
ideas.sort(function(a, b) {
if (moment(b.get('date')).isBefore(moment(a.get('date')))) {
return -1
} else {
return 1
}
});
this.set('content',ideas)
},
todaysIdeas: function(){
this.sortContent();
}.observes('content.[]'),
actions: {
save: function() {
var self = this;
var idea = this.store.createRecord('idea', {
body: this.get('body'),
tag: this.get('taggy')
});
idea.save().then(function(record) {
self.get('content').pushObject(record);
});
}
}
});
Aucun commentaire:
Enregistrer un commentaire