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" /> <context>jira.general</context> </web-resource>
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 ?
I think the problem is leading slash in location it should be templates/test.js
Hi Vishwajeet,
Even after removing the slash the script does not get executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using WebresourceManager to make sure the resources are loaded?
$webResourceManager.requireResourcesForContext("com.jtricks.plugin-key:resource-module-key")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vishwa Ah, I see what you mean. Thought he is trying to get it in some plugin templates.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vishwajeet: tried removing the space from the key but still script does not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
The original script does not work only alert statement worked .
AJS.$(document).ready(function(){ AJS.$('a').each(function(){ 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() window.location.href=burl+"/browse/"+pkey+"#selectedTab=com.atlassian.jira.plugin.system.project%3Aversions-panel"; }) } }) })
Is there something missing in the above script ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.