# הערך מחדש ווידג'טים בכותרת בעת שינוי נתיב ללא שגיאה

**URL:** <https://meta.discourse.org/t/re-evaluate-widgets-in-header-upon-route-change-without-error/262697>\
**Category:** Development\
**Created:** [24 באפריל,‏ 2023,‏ 11:57am UTC](https://meta.discourse.org/t/re-evaluate-widgets-in-header-upon-route-change-without-error/262697 "2023-04-24T11:57:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [24 באפריל,‏ 2023,‏ 12:47pm UTC](https://meta.discourse.org/t/re-evaluate-widgets-in-header-upon-route-change-without-error/262697/4 "2023-04-24T12:47:04Z")

</div>

Understood.

> [@david](#):
>
> Can you share more of your file (e.g. where is `hbs` being imported from?)

`import { hbs } from "ember-cli-htmlbars";`

Functionally I’m trying to swap the logo depending on the route. In reality I’m doing this by attaching an image to the home logo on some routes and overlaying the primary logo. I want that logic to be re-evaluated when moving between routes, which currently seems to work moving in and out of the Topic routes I’m guessing because the `header-contents` widget to which everything is attached has logic evaluating the `attrs.topic` which obviously changes when that occurs.

My `category-logo-widget` is attached like so:

```plaintext
      api.decorateWidget("home-logo:after", (helper) => {
        const currentPath = helper.register
          .lookup("service:router")
          .get("_router.currentPath");

        if (
          helper.widget.currentUser &&
          !helper.widget.site.mobileView &&
          currentPath.indexOf("discovery") === -1
        ) {
          return helper.attach("category-logo-widget");
        } 
      });

```

Which works fine, but is not being re-evaluated between certain route transitions, so isn’t fulfilling the requirement fully dynamically without a page reload.

> [@david](#):
>
> Also what version of Discourse is this? `site-header.js:337` does not currently reference a ‘header’ variable

oooooops, this could be the issue, I had a feeling it might be but my tests were obviously too superficial to rule this out.

I see this commit, I’ll need to update my dev instance … [PERF: Memoize element references for `dockCheck` (#21079) · discourse/discourse@db16700 · GitHub](https://github.com/discourse/discourse/commit/db16700355db6f76b6d88bdc47a18259a9ee77ff)

I’ll revert either way, thanks for your time!

---

_[View the full topic](https://meta.discourse.org/t/re-evaluate-widgets-in-header-upon-route-change-without-error/262697)._
