Rerender on new route or transition

I’m building a banner ad plug-in. I have a section of the DOM that I need to re-render each time the page transitions. I have attempted (unsuccessfully) both a Widget and Ember Component, but neither are updating. I loaded them via a Plugin Outlet. I even tried to simplify the problem and dump the current timestamp of the load to the screen (rather than a banner), but only get a re-render if I refresh the browser.

Can someone please point me in the right direction for a solution? I’ve been through the main Discourse developer tutorials, BTW. Just seems like I’m missing something simple.

In which place you are trying to render? In Discourse most of the header UI sections will not refresh across page transactions unlike you hit browser refresh.

And can you post your code to see how you are doing it.

The plugin outlet right above the topic list.

Maybe you can try the following code (not tested):

// My plugin initializer
export default {

	name: 'myPlugin',

	initialize(container) {

		// Reopen the router to add a didTransition hook
		const router = container.lookup('router:main')
		router.reopen({
			doSomething: function() {
				// Wait for rendering to be over. THIS DOESN'T WORK IN ALL CASES. 
				// In fact, there is no way to be sure rendering is complete, because 
				// a 'complete rendering' is meaningless (think about a looping DOM  
				// animation)
				Ember.run.schedule('afterRender', null, () => {
					// Do your stuff here
					...
				})
			}.on('didTransition')
		})

	}

}

¿Puede alguien orientarme más sobre esto?

¿Podrías explicarme qué estás intentando lograr?

Necesito agregar un componente en el área del pie de página y actualizar su contenido en cada carga de página cuando el usuario visita un tema. Se trata de un carrusel que muestra los temas más destacados de nuestra comunidad y solo es visible en la página de temas para usuarios anónimos. Por lo tanto, cada vez que un usuario visita un tema que aparece en el carrusel, esa diapositiva debe eliminarse del componente. Al montarlo mediante la siguiente salida del pie de página, el componente no se vuelve a renderizar.

Cuando se renderiza el “footer” en Discourse, la aplicación envía un “evento”.

El evento es inserted-custom-html:footer.

Puedes usar ese evento para actualizar el contenido de tu pie de página de la siguiente manera:

api.onAppEvent("inserted-custom-html:footer", () => {
  // agrega tu JS aquí
});

Hay algunos detalles adicionales aquí.

Esto debería funcionar para lo que estás intentando lograr. Si no es así, házmelo saber y publica el código que estás usando.

Me gustaría colocar contenido dinámico en la parte superior de la página de inicio (solo).

¿Cuál es la mejor práctica actual para que se vuelva a renderizar con cada transición de página a la página de inicio?

Agradecería cualquier enlace a un plugin existente que utilice esto.