ember.js show default nested route if none provided
In my ember app (1.0.0 production version) I have a URL structure as follows:
/item
/item/{specific-item-name-defined-in-routes}
The Router mapping looks a little like this:
App.Router.map(function () {
this.resource("item", function () {
this.resource("my-first-item");
this.resource("another-item");
...
});
});
If the user navigates to /item I want to display a specific post (e.g.
/item/my-first-item). I can do this by using the redirect method of the
route:
App.ItemRoute = Ember.Route.extend({
redirect: function () {
this.transitionTo('my-first-item');
}
});
Unfortunately with this approach if I manually type into the address bar
the URL /item/another-item it redirects me to /item/my-first-item. If I
then click a link in the app to this route it loads correctly.
Why the different behaviour between clicking and typing in a URL and how
can I work around this?
No comments:
Post a Comment