- Search queries
- Sort: client-side, no refiring of model hook
- Sort: server-side, refire model hook
- Pagination + Sorting
- Boolean values. False value removes QP from URL
- Global query params on app route
- Opt-in to full transition via refresh()
- replaceUrl by changing controller QP property
- w/ {{partial}} helper for easy tabbing
- link-to with no route name, only QP change
- Complex: serializing textarea content into URL (and subexpressions))
- Arrays
-
-
Save machty/8167051 to your computer and use it in GitHub Desktop.
@machty this works for a route like this ?
/letters?occup=Primary&state=NY&propertyRef=55
Primary, NY and 55 are some values from a Fixture Model
The route above is suppose to change when you click on a link
Thanks!
Are there any examples of using query params with an Ember.Select view?
Is it possible to pass an entire object to the queryParams?
For example:
queryParams: ['filters'],
filters: {
name: 'Ivan',
age: 666
}
In the address bar, in theory, it should look like this: ```?filters[name]=ivan&filters[age]=666
But how to do it?
Tried your Gist - https://gist.github.com/machty/7923797 - but in Ember 1.7.0 this don't work :)
@dlcwalkoff: Did you ever figure out an easy way to pass an object in the URL like that?
+1 on how to use objects in the query params (e.g., /book/5?filter[chapter]=Chapter1
). This style is used heavily in json api and should be supported by Ember. Any ideas on how to go about it? It's also recommended for paging /books?page[number]=1&page[size]=100
Just came up with a way to use object based query params which seems to work:
In the controller you need to map the controller property to your query param key:
queryParams: ['sort',{
entityNameFilterValue: 'filter[entity.entity-name]'
}],
Then in the routers model function you need to construct the params however you want based on the controller value:
model: function(params){
if(params.entityNameFilterValue){
params.filter = {};
params.filter['entity.entity-name'] = params.entityNameFilterValue;
delete params.entityNameFilterValue;
}
// do your store lookup now with params
}
Thanks for this!
@machty, the above doesn't work today, does it?
https://github.com/machty/ember.js/blob/9308d5558e818596141d175024c3c5be80c05b0a/packages/ember-routing/lib/helpers/link_to.js#L823