Javascript works in announcement banner but not when in web resource module.

Mizan Community Champion Nov 08, 2012

Hi All ,

I need to execute a javascript using web resource plugin module the same way it gets executed when i paste it in the announcement banner .

below is the xml

<web-resource key="my js" name="my js" >
        <resource type="download" name="test.js" location="/templates/test.js" />

can someone please help me with this ??

The script does not get executed and is not even seen in the page source ... how can i make this script work ?

2 answers

1 accepted

I think the problem is leading slash in location it should be templates/test.js

Mizan Community Champion Nov 08, 2012

Hi Vishwajeet,

Even after removing the slash the script does not get executed.

0 vote

Are you using WebresourceManager to make sure the resources are loaded?


Mizan Community Champion Nov 08, 2012

I am not using any .vm files . I have a javascript which redirect to a link when i add a version in JIRA . Now i need to embed this script in a plugin instead of pasting it in the announcement banner .

Do i need to include a .vm file as resource?

My plugin key has a space eg: my plugin , can this be a reason ?

@Jobin : you don't need this in scenario he has mentioned, once he set the context to jira.general it should be available on all pages irrespective of required resource statement

@Mizan : I suspected the space but I thought that's just an example, I haven't scene any code with space in key, you can quickly try removing the same.

@Vishwa Ah, I see what you mean. Thought he is trying to get it in some plugin templates.

Mizan Community Champion Nov 08, 2012

@Vishwajeet: tried removing the space from the key but still script does not work.

Mizan Community Champion Nov 09, 2012

now i can see the script in the page source as below

<script type="text/javascript" src="/jira/s/en_US-tp7cj4/768/3/1.0-SNAPSHOT/_/download/resources/com.mizan.jscripts.jscripts:test/test.js" ></script>

the script is a simple alert however it is not working . its works when pasted in the anouncement banner .

Is there something else i need to specify in the script since Jira version is 5.1.8 ?

Mizan Community Champion Nov 09, 2012

The script works now , i was not removing the javascript tags from the js file . after remving it it works ...

Thank you Jobin and Vishwajeet for your support .

I will select Vishwajeets answer first becoz Jobin already has a lot of karma ;)

Mizan Community Champion Nov 11, 2012

Hi ,

The original script does not work only alert statement worked .

                if(AJS.$(this).html() =='Merge'){
AJS.$(document.body).on('submit', 'form', function(){
var pkey=document.getElementById("project-config-details-project-key").innerHTML;
var burl=AJS.$("input[title='baseURL']").val()

Is there something missing in the above script ?

did you checked pkey and burl getting expecting values ?

Note: if you modified existing js file and added new code? if yes, then you need to restart jira

Mizan Community Champion Nov 19, 2012

Yes i get expected values .. the script works when its in announcement banner but not when in web resource plugin.

Even after a restart the script did not work ..

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

795 views 2 19
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