Static GitHub Issues

[2944] Middleware: on page ready?

prev: <img :src> is not loading files from /static
next: Env vars not loaded when running ava

Hi all! I have made a plugin that is using some DOM elements (to change scroll behavior, parallax, etc.). On page change, I had to refresh this plugin by giving new DOM elements of the new page. So I've made this in a custom middleware. --> I get my new DOM elements and then refresh the plugin. But I have to do this in a setTimeout because middlewares are executed before the new page replaces the old one...

My question: Is there a better way to achieve this kind of thing? For example, using a hook like app.onPageReady() or whatever.

I have seen the app.router.afterEach() function but it's not matching with my needs. Thanks by advance

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2554">#c2554</a>)</em></sub></div>