Batch.js TypeError: $ is not a function

The same script works with an older Jira Plugin.
I created a brand new report plugin today using the tutorials posted online.

Plugin is running, but getting this error in the browsers console:
batch.js TypeError: $ is not a function

Which points to this:
/ module-key = ‘com.atlassian.tutorial.myPlugin:myPlugin-resources’, location = ‘/js/myPlugin.js’ /
$(function(){$("#container").highcharts({title:{text:“Burndown Chart”,x:-20}…

Note 1: highcharts.js is located in the same folder as myPlugin.js.
Note 2: highcharts.js has been added to atlassian-plugin.xml

Please advise.

replaced

$(function()

with


AJS.$(function ()

and it seems to be working now.

There’s nothing wrong with what you’ve got there, but if you also want to ensure that your JS code runs only after the page has loaded, this is a suitable pattern:

AJS.toInit(function($) {
    ...
})(AJS.$);
1 Like