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 Join to answer
Community showcase
Louis De Jaeger
Posted yesterday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

154 views 12 3
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot