Execute javascript code when page is loaded

In your javascript, inject the ‘jira/util/events’ module and bind to NEW_CONTENT_ADDED with the reason ‘pageLoaded’. That’s how I do it.

require([
		'jira/util/events',
	  	'jira/util/events/types',
	  	'jira/util/events/reasons'
 	 ], function(Events, EventTypes, EventReasons) {

	"use strict";
	
    Events.bind(EventTypes.NEW_CONTENT_ADDED, function(e, jiraContext, reason) {
        // Do your stuff here but check for the reason first to avoid being called too often
    });

3 Likes