lcoq
lcoq

Reputation: 10726

Router v2.1 transitionTo does not work

I'm trying to use the new Router API (at commit 6a165ad), and I have some problems.

Given this router:

Router.map(function(match) {
  match("/posts").to("posts", function(match) {
    match("/new").to('new', function(match) {
      match("/author").to('author');
    });
  });
});

I'm trying to transition to the new route.

Using new.index: this.transitionTo('new.index')

It works, but as you can see the route name is not really explicit (we don't even know that it's for a new post). It's consequently not a viable solution.

Using posts.new: this.transitionTo('posts.new')

I hoped it works, but an error is thrown:

The route posts.new was not found.

I believed the transition to the index was made automatically, but it seems not.

Using customized route name:

Since the commit specified above, Ember allows custom route naming. As my previous attempt does not work, I tried to force the new route to be posts.new, but it still does not work (idem if it was foo.new).

It looks like its not possible to go to a customized route that has nested routes.

TL;DR

Upvotes: 0

Views: 342

Answers (1)

Yehuda Katz
Yehuda Katz

Reputation: 28703

This was actually a bug in Ember. Because index is implicit, you should not need to explicitly provide it.

The bug was fixed on master.

If you want to go to a route that has child routes, you should transitionTo the specified name of the route, and Ember will automatically add the index for you.

Upvotes: 1

Related Questions