# איך לדעת אם הדף נטען ברכיב תמה / ווידג'ט?

**URL:** <https://meta.discourse.org/t/how-to-tell-if-page-is-loading-in-theme-component-widget/190190>\
**Category:** Development\
**Created:** [12 במאי,‏ 2021,‏ 1:41pm UTC](https://meta.discourse.org/t/how-to-tell-if-page-is-loading-in-theme-component-widget/190190 "2021-05-12T13:41:26Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Zach\_Swinehart](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zach_swinehart/32/210979_2.png) [@Zach\_Swinehart](https://meta.discourse.org/u/Zach_Swinehart)\
**Post date:** [2 ביוני,‏ 2021,‏ 10:48am UTC](https://meta.discourse.org/t/how-to-tell-if-page-is-loading-in-theme-component-widget/190190/10 "2021-06-02T10:48:56Z")

</div>

I managed to finally find a solution. Spent sooooooooooo long on this and IMO it’s worth merging into core because honestly it feels like it should already exist anyway in core.

I added the code below to my theme component; what it does is adds a “loading” class to the body as soon as routing starts, and then removes it as soon as routing is complete. Maybe this would be simple/obvious for folks who know ember, but it took me an obscenely long time (and trying a million things + reading through all threads on here I could find) to figure out.

With this core code in place, I can add loading spinners and such to my different widgets that will have their css and visibility be driven by whether or not the body tag has the `loading` css class.

```plaintext
initialize() {
    withPluginApi("0.8.8", (api) => {
      const router = api._lookupContainer('router:main');
      router.reopen({
        addLoadingCSSClassToBody: function() {
          document.body.classList.add("loading");
        }.on('willTransition')
      });

      router.reopen({
        removeLoadingCSSClassFromBody: function() {
          document.body.classList.remove("loading");
        }.on('didTransition')
      });
    });
  },
};

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-tell-if-page-is-loading-in-theme-component-widget/190190)._
