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

This widget could not be displayed.

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?

This widget could not be displayed.

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
Posted 3 hours ago in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

9 views 0 0
View post

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