# Route update never show

**URL:** <https://discourse.elm-lang.org/t/route-update-never-show/1614>\
**Category:** Learn\
**Created:** [August 7, 2018, 3:46pm UTC](https://discourse.elm-lang.org/t/route-update-never-show/1614 "2018-08-07T15:46:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdxiong](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/tdxiong/32/986_2.png) [@tdxiong](https://discourse.elm-lang.org/u/tdxiong)\
**Post date:** [August 7, 2018, 3:46pm UTC](https://discourse.elm-lang.org/t/route-update-never-show/1614/1 "2018-08-07T15:46:49Z")

</div>

1. By some help here, I finally get a 2 pages with routing working, my init and update code is below:

What I do not understand is, whenever I enter the 2 location, or click the links on 2 pages to jump around, the console always show “initRoute” only, never show “updateRoute”. The LocationChanged location msg will always be generated right? Why didn’t it show up?

1. I used above approach to handle routing between different pages, am I doing it correct? Are there better way?

Thanks.

---

<div class="post-metadata">

**Author:** ![berryg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/berryg/32/373_2.png) [@berryg](https://discourse.elm-lang.org/u/berryg)\
**Post date:** [August 7, 2018, 4:13pm UTC](https://discourse.elm-lang.org/t/route-update-never-show/1614/2 "2018-08-07T16:13:45Z")

</div>

When using routing I just store the `newRoute` in the `Model` in the `init` function. And, in the `update` function I just update the new Location in the `Model`. So, the `model` always contains an up to date location. Then in the `view` function I have a `case-of` statement to show the correct content based on the location stored in the `model`.

In your `update` function I see you are not updating the model, but using `initialModel` instead. Looks to me you are resetting your model to its initial state each time you change the location. Is that what you want?

---

<div class="post-metadata">

**Author:** ![tdxiong](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/tdxiong/32/986_2.png) [@tdxiong](https://discourse.elm-lang.org/u/tdxiong)\
**Post date:** [August 7, 2018, 4:42pm UTC](https://discourse.elm-lang.org/t/route-update-never-show/1614/3 "2018-08-07T16:42:05Z")

</div>

my initialModel will set the route in model to current route, and view in case of current route

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [August 17, 2018, 4:44pm UTC](https://discourse.elm-lang.org/t/route-update-never-show/1614/4 "2018-08-17T16:44:35Z")

</div>

Closed on August 17, 2018, 4:44pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
