# Problem with Aurelia.setRoot()

**URL:** https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012
**Category:** Help Requests
**Created:** [December 12, 2018, 1:16pm UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012 "2018-12-12T13:16:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![AndreaProgrammerIt](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@AndreaProgrammerIt](https://discourse.aurelia.io/u/AndreaProgrammerIt)
#### Post date: [December 12, 2018, 1:16pm UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/1 "2018-12-12T13:16:18Z")

</div>

Hi all,

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

In the first change of aurelia root it works.

![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/6/6a8449c002ef7c70b4917998629bd752fc3184d5.png)

When I want return to the other root:  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/c/c67582a57fac32e8d886b27da02a3fac42ac245a.png)

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 ?

---

<div class="post-metadata">

### Author: ![AndreaProgrammerIt](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@AndreaProgrammerIt](https://discourse.aurelia.io/u/AndreaProgrammerIt)
#### Post date: [December 12, 2018, 1:47pm UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/2 "2018-12-12T13:47:32Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![AndreaProgrammerIt](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@AndreaProgrammerIt](https://discourse.aurelia.io/u/AndreaProgrammerIt)
#### Post date: [December 12, 2018, 2:04pm UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/3 "2018-12-12T14:04:38Z")

</div>

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

Any help?!

---

<div class="post-metadata">

### Author: ![davismj](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davismj/32/267_2.png) [@davismj](https://discourse.aurelia.io/u/davismj)
#### Post date: [December 13, 2018, 4:15am UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/4 "2018-12-13T04:15:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![AndreaProgrammerIt](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@AndreaProgrammerIt](https://discourse.aurelia.io/u/AndreaProgrammerIt)
#### Post date: [December 13, 2018, 9:13am UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/5 "2018-12-13T09:13:58Z")

</div>

Hi davismj,

I’m trying everything possible:

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/2/299f3e48839ecec1995717a56b68032cb1d17918.png)

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.

---

<div class="post-metadata">

### Author: ![davismj](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davismj/32/267_2.png) [@davismj](https://discourse.aurelia.io/u/davismj)
#### Post date: [December 13, 2018, 10:25am UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/6 "2018-12-13T10:25:54Z")

</div>

> 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](https://gist.run/?id=9975a6d7b351c1671c3c1bdfab34ed2c)

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](https://aurelia.io/contact), who will get on a call with you and work with you to solve your particular issue quickly.

---

<div class="post-metadata">

### Author: ![AndreaProgrammerIt](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@AndreaProgrammerIt](https://discourse.aurelia.io/u/AndreaProgrammerIt)
#### Post date: [December 19, 2018, 1:58pm UTC](https://discourse.aurelia.io/t/problem-with-aurelia-setroot/2012/7 "2018-12-19T13:58:53Z")

</div>

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
