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')
		})

	}

}

Qualcuno può fornire ulteriori indicazioni in merito?

Puoi per favore spiegare cosa stai cercando di ottenere?

È necessario aggiungere un componente nell’area del footer e aggiornarne il contenuto ad ogni caricamento della pagina quando un utente visita un argomento. Si tratta di uno slider che contiene gli argomenti principali della nostra comunità ed è visibile solo nella pagina degli argomenti per gli utenti anonimi. Quindi, quando un utente visita un argomento presente nello slider, quella diapositiva deve essere rimossa dal componente. L’installazione tramite la seguente outlet del footer non provoca il re-render del componente.

Quando il “footer” viene renderizzato in Discourse, l’app invia un “evento”

L’evento è inserted-custom-html:footer

Puoi utilizzare quell’evento per aggiornare il contenuto del tuo footer in questo modo

api.onAppEvent("inserted-custom-html:footer", () => {
  // aggiungi qui il tuo JS
});

Ci sono alcuni dettagli in più qui.

Questo dovrebbe funzionare per ciò che stai cercando di ottenere. Se non funziona, fammi sapere e pubblica il codice che stai utilizzando.

Vorrei inserire un contenuto dinamico nella parte superiore della homepage (solo).

Qual è attualmente la best practice per farlo renderizzare nuovamente ad ogni transizione di pagina verso la homepage?

Apprezzerei qualsiasi link a un plugin esistente che lo utilizzi.