ember-query-params icon indicating copy to clipboard operation
ember-query-params copied to clipboard

`setParams()` doesn't fully work when params being set trigger model refresh from route.

Open camatangelo opened this issue 9 years ago • 2 comments

Not sure if this is more of an issue with Ember or not, but I'm trying to set multiple query params in a component with setParams(), however since both of these params trigger a model refresh on one of my routes, the model hook fires as soon as the first param is changed (in this case category) and does not set any params after it (in this case name).

// component
this.get('paramsRelay').setParams({
  category: '',
  name:     ''
});
// route
export default Route.extend(AutosubscribeMixin, {

  queryParams: {
    category: {
      refreshModel: true
    },
    name: {
      refreshModel: true
    }
  },      

  model(params) {
    // ...
    // fires as soon as category is changed
  }

 // ...

camatangelo avatar May 11 '16 20:05 camatangelo

Agreed. Not sure there is a nice solution for this at the moment. cc @rwjblue @raytiley

I think the alternative would be to use transitionTo({ queryParams: { ... } }).

knownasilya avatar May 11 '16 20:05 knownasilya

FWIW, the model hook can also be called twice when navigating using link-to, or at least that's what happens in this trimmed down example app (see console logs)

jbourassa avatar May 12 '16 20:05 jbourassa