UPDATE: this is different from the Route-only approach i was suggesting recently; we're keeping things on the controller, but route-specific config lives on a queryParams
config hash on the route
query-params-new needs another iteration, described here https://gist.github.com/machty/d687cab552ecee2f9162
From the bottom of http://emberjs.com/guides/routing/query-params/
These are examples from the QP guides on the ember site, rewritten according to the proposed API described at https://gist.github.com/machty/d687cab552ecee2f9162
Original: http://emberjs.jsbin.com/ucanam/3008/edit
Changes: None
Original: http://emberjs.jsbin.com/ucanam/2937/edit
Changes: None
Original: http://emberjs.jsbin.com/ucanam/2942/edit
Same controller modifications as previous, but route is a bit different:
App.ApplicationRoute = Ember.Route.extend({
queryParams: {
sortBy: {
refreshModel: true
}
}
// no longer have to do the
// queryParamsDidChange + refresh() incantation
});
Original: http://emberjs.jsbin.com/ucanam/2950/edit
No change
Original: http://emberjs.jsbin.com/ucanam/2708/edit
Nothing changes in the code; the main Ember change happening here is that we now serialize boolean values into the URL as &x=true& and &x=false&, rather than just &x& to imply that x is true and false if absent from URL. This avoids the issue of ambiguity wrt deserializing true and false as strings "true" and "false" by inferring from the default value, which is a boolean, that the URL should be deserialized as booleans rather than strings.
I think this is pretty rad.
Original: http://emberjs.jsbin.com/ucanam/2719/edit
No Change
Original: http://emberjs.jsbin.com/ucanam/2711/edit
App.IndexRoute = Ember.Route.extend({
queryParams: {
foo: {
refreshModel: true
}
}
// get rid of queryParamsDidChange
});
the rest are about the same.
query-params-new
responded to all QP prop changes with a
replaceState
. The new default is going to be pushState
, but we're
also adding a way to make this configure, e.g.:
App.IndexRoute = Ember.Route.extend({
queryParams: {
foo: {
replace: true
}
}
});
replace: true
is mimicking the link-to replace=true
API, if you're
wondering.
Is there a difference between defining queryParams in the route vs the controller?