Robert
Robert

Reputation: 816

Ember query params for nested routes

I have the url /tests/test-slug?extradata=data all my params are setup correctly within ember. When that extradata param is set the model updates with the new data from the (/tests/test-slug?extradata=data) response. Usually I would retrieve data using ember-model by doing:

model: function (params) {
  return App.Test.findQuery(params);
}

But with the query parameter added to this nested url its giving me 'test-slug' as a param with the extradata and making a request to the server with: ?tests_slug=test-slug&extradata=data

Is there anyway I can use query params and update my model on a nested route?

Edit: this post explains it a lot better than me: Ember data - dynamic segments and query params together?

Upvotes: 3

Views: 2049

Answers (2)

jesenko
jesenko

Reputation: 1293

This PR should enable this scenario, but is not yet merged into Ember.Data.

Until then you could override findQuery method on ApplicationAdapter, such that id param would be passed as part of url and other params as query params. See JsBin for example.

Upvotes: 1

encrypter8
encrypter8

Reputation: 31

Extend your route's params with the parant route's params and send that into .findQuery()

Ember.$.extend(params, this.paramsFor('parentRoute'));

More: http://emberjs.com/api/classes/Ember.Route.html#method_paramsFor

Upvotes: 3

Related Questions