Reputation: 73
For searching hotels, my initial routes look like
App.Router.map ->
this.resource('hotels',
path: '/hotels/:city/:country/:checkin/:checkout/', ->
this.resource('hotels.sort',
path: '/sort/:method'
)
)
In the child route;
App.HotelsSortRoute = Ember.Route.extend
model: (params) ->
console.log(params);
only returns {sort: price}
The excellent resource at Ember deeply nested routes do not keep parent dynamic parameter hints that using this.modelFor
will return the parent model.
However, the query that is fired to the backend (sorting hotels in a different way) will also return different results (since it has a pagination of about 20 hotels).
How do I go about firing a new request to the server for sorting, without reloading the entire page?
Upvotes: 0
Views: 43
Reputation: 2890
Ember loads route's models one by one starting with highest of routes hierarchy. Because of that, you can't avoid firing request for parent's model while waiting for full load of all routes. You can set breakpoints in model hooks to explore that.
In your case, I'd advise to hoist 'sort' param to parent route and to remove child route at all. You can always set default sorting after all.
Upvotes: 1