Unable to remove query string using can.route

I am trying to remove query string from route using can.route.removeAttr but I do not see it remove from address bar on Chrome / Safari.

Please download the code from JSBin https://jsbin.com/gijiqab/edit?html,js,output and try as JSBin for some reason does not show the updated URLs.

In that example, page is part of route. However query is a query string which I want to remove and add whenever necessary. How can I do that using CanJS?

This is a bug. You can work around it like:

DefineMap does not support removeAttr. However, setting to undefined will achieve the same thing. We should make removeAttr set a DefineMap to undefined.

1 Like

Thanks for the work around :slight_smile:

I always thought, can.route is an instance of can.Map. Hence was using .attr() instead of .get()

In 3.0 it can be either DefineMap or Map. If DefineMap is loaded, it will default to DefineMap.

1 Like