Current PageTracker.current?


(Jesse Perry) #1

Is there a new way to get a Javascript event when page URL changes? Discourse.PageTracker.current is not working for me.


(Joe) #2

I’ve had some luck with something like this. (May not be the most optimal way :sweat_smile:)

<script type="text/discourse-plugin" version="0.8.16">
api.onPageChange(() => {
	foo();
});

function foo() {
	// do stuff
	console.log(" foo loaded");
}
</script>

(Jesse Perry) #3

Thank you! That seems to be the best way currently. Also found it referenced here: