I've a simple application which fetches records for a given period, and support paging the results:
// routes
this.resource('visits', function() {
this.route('list', { path: '/:period' });
});
// 'visits' template
.menu
link-to %a.item 'visits.list' 'today' (query-params page=1)
| Today
link-to %a.item 'visits.list' 'yesterday' (query-params page=1)
| Yesterday
link-to %a.item 'visits.list' 'week' (query-params page=1)
| Current Week
I wanted every time a period is clicked, it's reset to page 1. The problem is that by doing so when I go to any other page different than 1, the current period in the link-to is no longer active.
e.g: http://localhost:4200/visits/today?page=5
I tried to solve this resetting the params, or adding defaults to the controller as described here:
- http://emberjs.com/guides/routing/query-params/
- http://discuss.emberjs.com/t/link-to-helper-to-reset-query-param-s-to-null/6276
However neither of both solutions are working for me, since I'm not exiting the controller. Is any way to make link-to to ignore an specific query-param and stay active?
Update:
Here's a JSBin with this issue: http://emberjs.jsbin.com/mulonulefi/4/edit
Thanks!