Reputation: 301
I am using the new query-params in Ember.js to filter entries by date. I have added a field to add new entries, with the date being automatically assigned as the query date. When a new entry is added it only shows up on the page when I refresh. Is there any way to retrigger the query without changing the query itself?
Controller: (simplified)
queryParams: 'date'
date: null
filteredEntries: ( ->
date = @get('date')
model = @get('model')
if (date)
return entries.filterProperty('date', date)
else
return entries
).property('date', 'model')
actions:
createEntry: ->
entry = @store.createRecord('entry', { date: @get('date') })
entry.save()
I also tried this, but it didn't work:
entry.save().then -> this.transitionTo({queryParams: { date: @get('date')}})
Upvotes: 1
Views: 338
Reputation: 3591
I think this is what you are looking for (in your route):
App.MyRoute = Ember.Route.extend({
queryParams: {
date: {
refreshModel: true
}
},
});
This will refresh your model everytime the value of date
changes.
Upvotes: 2