Problem with Aurelia.setRoot()

Hi all,

i have a problem with Aurelia.setRoot(PLATFORM.modulename(etc)).

In the first change of aurelia root it works.

image

When I want return to the other root:
image

it doesn’t work. I have to press 2 times the button and if it change view the view isn’t loaded.

‘attached()’ event is not called… anyone know the problem ?

I found a help in internet:

If I call:
" this._router.reset(); " it seems working but at the first time of the root’s change I have to press the button 2 times… in the others times it works always at the first click.

Problems also with “router.reset()”.
It reset all routers so I can’t change view.

Any help?!

You need a stack trace or some more information from your console.

You probably are setting the root without configuring a route or a route redirect.

Hi davismj,

I’m trying everything possible:

What do you suggest?
I try “location.reload()” / “router.reset()” / change positions of the calls… but nothing.

Only the first setRoot works, than the site continue without a router configured.

What do you suggest?

The first thing you should always do when looking for help is to create a reproduction using gist.run, etc. I did this for you: GistRun

As you can see from the example above, I am able to switch back and forth between roots A and B and routes One and Two without issue. That tells me that the issue might be in your code specifically.

In the example above, when you switch from A to B, you’re either at #/one or #/two, which are both configured on both roots A and B. Chances are you are switching from root A route #/two to root B where route #/two is not configured.

Try adding config.mapUnknownRoutes('one') to your configureRouter() function, to whichever route is your “home” route in that root.

If that doesn’t work, I recommend that you (a) modify the gist.run above to demonstrate what the issue is and / or (b) reach out to Aurelia support, who will get on a call with you and work with you to solve your particular issue quickly.

1 Like

Thank you a lot man.

But I have to say that I already changed the configuration of treeviews …
Now I have only one “big” (about 12-15 views to route) route where I do routing.
For the moment I’m ok.

Next time I will retry to use 2 different routes.

Thank you again,
Andrea