I found jsbin that illustrates my problem. http://emberjs.jsbin.com/ucanam/2708 .
This last link, in which there are no explicit request parameters specified in link-to, it uses the current value of the sticky request parameter on the controller. Is there a way to disable this sticky feature? Does this break other scenarios?
My current solution is to reset the request parameters on each route that I want to clear:
export default Ember.Route.extend({ deactivate: function() { var controller = this.controllerFor(this.get('controllerName')); var queryParams = controller.get('queryParams'); for (var i = 0; i < queryParams.length; i++) controller.set(queryParams[i], null); } });
This works, but it seems that there should be an easier way.
I should note that doing something like {{#link-to 'route' (query-params val=null)}}{{/link-to}} is not an option for each route, because I have code reusable where the route is a variable, so I wonβt know the request parameters that I have to reject.
Edit:
Here is the right way to do this if you change the document from the answer:
export default Ember.Route.extend({ resetController: function(controller, isExiting) { if (isExiting) { var queryParams = controller.get('queryParams'); for (var i = 0; i < queryParams.length; i++) controller.set(queryParams[i], null); } } });
Edit 2:
Now it is very easy to do using this add-on https://github.com/kellyselden/ember-query-params-reset . It also resets to its original values, and not only resets the values.
Kelly selden
source share