how to add javascript in jira 5.1.1

I want to upgrade a plugin, but the Javascript in the plugin is not work. The javascript controls the "change" event of a "Select".

I have seen this:

The way to use JS has been changed since JIRA 5.0+, would someone give me some ideas.

Its source code is like this:

original JS:

AJS.toInit(function() {
    (function($) {
     $('#select-issue-type').change(function() {
          var projectKey = $('#project-key').val();
          var issueType = $('#select-issue-type :selected').val();
          $.get('../GetFieldsHtmlAction.jspa?projectKey=' + projectKey + '&selectedIssueTypeId=' + issueType, function(data) {

Original .vm:

<div id="fields">	

Original atlassian.xml:

<web-resource key="cpjiadminrs">
       <resource type="download" name="cpjiadmin.js" location="js/cpjiadmin.js"/>
       <resource type="download" name="cpjiadmin.css" location="css/cpjiadmin.css"/>

2 answers

Have you tried setting the context to atl.general?

<web-resource name="AAC Connector Resources" i18n-name-key="" key="aac-connector-resources">
<description key="aac-connector-resources.description">The AAC Connector Resources Plugin</description>
<resource name="aac-connector.css" type="download" location="assets/css/aac-connector.css"/>
<resource name="aac-connector.js" type="download" location="assets/js/aac-connector.js"/>
<resource type="download" name="assets/" location="assets/"/>

please try.

#requireResource("your plugin key+ :cpjiadminrs")

in your velocity template it should work.

yes, there is <context>atl.general</context> in the <web-source>

and at the head of the related vm file has the following:

   &lt;meta name='decorator' content='atl.general'&gt;

Thank you for your kindly answer, but it still not work. 555... I want to cry.

The css in the web-source can be added correctly, but the javascript could not be executed.

Does it need to modify the javascript file?

No need to edit the java script.

make sure your additing this entry in the atlassian-plugin.xml file.

<web-resource key="scriptaculous" name="scriptaculous" >

<resource type="download" name="yourfile.js" location="temp/res/yourfile.js" />


and then go to your velocity file and edit it to the .

#requireResource("your plugin key+ :cpjiadminrs")

make sure and check the syntax for the #requireResource on atlassian it will be help ful for you

if still not working then i cannot help you then you can really cry.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Statuspage

194 years of downtime: looking back on incident data from 2018

Statuspage customers logged more than 194 years of collective incidents in 2018. That’s a whopping 87% increase from the  104 years logged in 2017 , and we aren’t even through December yet....

36 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you