Upgrading to Jira 9 : jQuery or AJS are not accessible on pages with deferred scripts


We have used jQuery and AJS in announcement banner.
This is working fine in Jira 8.x, however after upgrading to Jira 9.4 the jquery functions have stopped working. A javascript error can be seen in Inspect Console “Uncaught ReferenceError: $ is not defined”

The upgrade doc Preparing for Jira 9.0 | Atlassian Support | Atlassian Documentation does mention about this degradation.

Can someone please help advice what change in the javascript needs to be done to make the jquery function start working in Jira 9.4


document.addEventListener("DOMContentLoaded", () => {
// your code goes here, AJS and jQuery will have been loaded when this runs
1 Like

Thanks Paolo, the JS error seems to have gone.

Can you please help in another issue in the same context.
Below is the code:
AJS.$(‘dl.links-list dd’).each(function()
var objDD = this;

var objIssueLink = AJS.$(objDD).find(‘a’);
var linkedIssueKey = “”;
if (objIssueLink.length) {
linkedIssueKey = AJS.$(objIssueLink).attr(“data-issue-key”);

With the suggested solution, this above code is returning linkedIssueKey as undefined.

if (objIssueLink.length) {
linkedIssueKey = AJS.$(objIssueLink).attr(“data-issue-key”);

objIssueLink is an array, shouldn’t you be doing something like AJS.$(objIssueLink[0]).attr(“data-issue-key”);?