I have some routes defined like:
Router.map(function() {
this.route('foo', function() {
this.route('bar');
this.route('bar', {path: 'bar/:fooid'});
});
// ...
});
The dynamic segment in /foo/bar/:fooid
is an id that can be validated against some rules. To simplify the example, let's assume :fooid
must consist of exactly 3 digits.
If an invalid value gets passed like in /foo/bar/1234567
, I want reset the to url to foo/bar/
.
Simplified foo.bar route:
export default Ember.Route.extend({
model (params) {
// If fooid is invalid, set model.fooid.isValid to false
},
afterModel (model, transition) {
// If fooid is invalid...
this.transitionTo('/foo/bar/');
}
});
The validation process itself works but I can't get rid of the wrong :fooid
parameter in the url!
If I transition to a different route it works fine.
Ember version is 2.14
Aucun commentaire:
Enregistrer un commentaire