after save model in view, the data in view are empty. For example if I add an comment to post and after saving the post my view is empty, no data will display. Why? How I solve the problem?
var post = this.get('model');
var comment = this.store.pushObject('comment');
comment.set('text', ' thats some text');
comment.set('created', '11111212');
comment.save().then(function(resolvedComment){
post.get('comments').addObject(resolvedComment);
post.save();
});
actions:{
createIncidentComment: function(){
var post = this.get('model');
var state = post.get('postState');
var newComment = this.get('newComment');
var date = Date.now();
var currentUser = this.get('controllers.application.user');
var contr = this;
if(newComment!= null){
var comment = this.store.createRecord('comment',{
comment: newComment,
created: date,
context: postState,
reporter: currentUser
});
comment.save().then(function(){
post.get('comments').pushObject(comment);
post.save();
});
}
}
}
});
Although you’ve found a workaround, it is still ugly: you have to reload the model by issuing an extra HTTP request. I’ve created a JSBin to demo the problem: http://jsbin.com/EWUSEkA/3/edit?html,js,output