mercredi 6 janvier 2016

emberjs share sticky query params across models

I have a route in ember defined as such

this.route('products', { path: '/t' }, function() {
  this.route('index', { path: '/:taxon' });
});

So I am able to visit the following URLs:

  • /t/shirts
  • /t/shoes
  • /t/etc...

each of these may have a series of query parameters also. For example I could make a request for red shirts like this /t/shirts?colour=red. This is great but I want to persist the query parameters across the controller instance instead of the model. So if I was searching for red shirts and then transitioned to looking at shoes (via a {{#link-to}}) then the query parameters would be available on that route too i.e. /t/shoes?colour=red. Currently I don't seem to be able to do this.

I found a reference to something in the ember documentation that states I can set showMagnifyingGlass's scope to "controller" and this will do what I intend but it does not seem to be working. Have I got the wrong end of the stick with showMagnifyingGlass? I believe the point of this is scope the query parameters to the controller instance and not the model so that if I were to click on a link that changes the routes model it does not affect the query params.




Aucun commentaire:

Enregistrer un commentaire