# router in a live page

**URL:** <https://forums.fusetools.com/t/router-in-a-live-page/2375>\
**Category:** How-to Discussions\
**Created:** [November 9, 2016, 4:37pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375 "2016-11-09T16:37:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [November 9, 2016, 4:37pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/1 "2016-11-09T16:37:36Z")

</div>

Hi,

after 0.29 we can create live pages and not just templates in a navigator / router. My question is: how do i call the router inside the live page js ?

For example:

```
 <Router ux:Name="myRouter" BackButtonAction="None"/>
            
 <Navigator>
   <Page Name="page1">
     <ux:Include File="Page1.ux" />
   </Page>

   <TemplatePage ux:Template="templatePage" router="myRouter" />
 </Navigator>

```

TemplatePage class would look similar to:

```
<Panel ux:Class="TemplatePage">
    <Router ux:Dependency="router" />
    <JavaScript File="templatePage.js" />

```

so i would be able to call router.push from the templatePage.js

my question is: how do i call the router from the Page1.js (that would be declared in the Page1.ux) ?

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [November 9, 2016, 4:42pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/2 "2016-11-09T16:42:52Z")

</div>

Hi!

This works the same as for when you use ux:Template. Here is an example:

```auto
<App>
	<Panel>
		<Router ux:Name="router" />
		<Navigator DefaultTemplate="page1">
			<Page ux:Name="page1" Color="Yellow">
				<JavaScript>
					function pushPage2() { router.push("page2"); }

					module.exports = { pushPage2 };
				</JavaScript>
				<Button Text="Page2" Clicked="{pushPage2}"/>
			</Page>
			<Page ux:Name="page2" Color="Red">
			</Page>
		</Navigator>
	</Panel>
</App>

```

---

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [November 9, 2016, 4:48pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/3 "2016-11-09T16:48:35Z")

</div>

Hi!

that’s what i expected but in my app i got a “router is not defined”… but i will check and if i’ll upload a an example if i don’t find the error.

thnx!

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [November 9, 2016, 5:04pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/4 "2016-11-09T17:04:01Z")

</div>

Make sure you do  
`myRouter.push`  
and not  
`router.push`

in that case. Since the name of your router is `myRouter`

---

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [November 9, 2016, 5:11pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/5 "2016-11-09T17:11:53Z")

</div>

yes i did (actaully i got a "myRouter is not defined)

I saw where is the error but i guess it may be a bug (i did a workaround) as it depends on when i call “myRouter.push” inside the page1.js (in one function it works in the other i get the “myRouter is not defined” (same code))

Can u pls tell me where can i upload an example?

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [November 9, 2016, 5:29pm UTC](https://forums.fusetools.com/t/router-in-a-live-page/2375/6 "2016-11-09T17:29:34Z")

</div>

Its quite hard to help since i have no idea whats behind your ux:Include

```auto
<ux:Include File="Page1.ux" />

```

Repro cases can be uploaded here :

> **[Dropbox - Submit files](https://www.dropbox.com/request/ZgndLtJQm5eGzG9cicGK)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!
