Query Params and Template Updating


Can someone just tell me how I can update the template after calling createRecord, when the router is using this.store.query?

I am using this.query so that I can use query parameters.

I do find that using findAll updates the template automatically, I understand why query doesn’t but I still need it to. I use to use filter() but now that is deprecated I am reluctant but they seem happy to deprecate things without actually specifying what the alternative is supposed to be.


Ok I missed the queryParams property in the route. Going to try that.

I am still interested to know how you update the template of a parent route (that has this.store.query in the model() callback) when you add a createRecord() in a component of a child route


Nope doesn’t work. The server is not receiving any params when using findAll, only with this.store.query() do params get sent but then the template is not updating, I understand why but I still need it updating,

Using findAll does update it but I can’t send params. Stuck between a rock and a hard place. Yet such a simple request of functionality.


I’m not sure I understand your question, but if what you want to do is refresh the model when the query params change, then you need to specify the query param on both the controller and the route. In the route, you must specify refreshModel: true

export default Ember.Route.extend({
  queryParams: {
     category: {
      refreshModel: true

Is that what you are trying to do? If not, can you give a bit more explanation of what you’re trying to accomplish?

This is described in the guides: https://guides.emberjs.com/v2.5.0/routing/query-params/


I’m having the same problem as @Ben_Glancy. My model method in the route is doing a query in the store, something like this:

return this.store.query('goal', { filter: { userId: 10 } });

Given that in the same route I have an action that creates and saves a new goal (that belongsTo an User). I woul like to see the query to be updated after saving a new record that matches the query, but I’m not seeing that. It works fine with findAll though.


How would Ember know where to display your new record, where would it belong?

If you were to refresh the page, would your new record even appear in the list? How does Ember.js know what Query() is returning. findAll is more specific so assumptions can be made.

You have to manually refresh. I think in one case I created two lists, list 2 to add new records to (irrelevant of what was in list 1). I put list 2 under list 1 to make them look like the same list…smoke and mirrors.


@Ben_Glancy thanks, I solved this by using this.refresh(); in the return the promise in the route.