Reputation: 1516
I want to reload a route after a .save()
(in controller). Currently, ember-data is changing the status in the store but whatever I tried for reloading the route didn't work. The problem is I want to reload the current route based on conversation status.
For example, if I'm currently in status=opened
and I close the conversation, I want to reload the route status=opened
. I noticed that because the status param doesn't change, the route is not reloaded!
I tried doing a this.store.find('conversation', { status : currentStatus })
, but it doesn't work.
How can I do this? I can edit for more details if needed.
I have this model hook :
model: function(params){
return this.store.find('conversation', { status : params.status});
},
queryParams: {
status: {
refreshModel: true
}
}
When I want to change the status a conversation, I'm using the following :
this.store.find('conversation', conv.id).then(function(conversation){
conversation.set('status', 'closed');
conversation.save();
});
Upvotes: 1
Views: 363
Reputation: 47367
Do the filter both server and client side, and then you don't need to reload the route, it'll be much cheaper.
model: function(params){
return this.store.filter('conversation', { status : params.status}, function(rec){
return rec.get('status') === params.status;
});
},
http://emberjs.com/api/data/classes/DS.Store.html#method_filter
Upvotes: 1