Home

Issue: 2944

Middleware: on page ready?

[issue link]

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

This question is available on Nuxt.js community (#c2554)