web-resource contexts

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2012

how to include javascript on create and transition screens only ? because from javascript i am making rest call and loading javascrip as webresource and context as atl.general, due to this javascript will loading in all pages. so i want to restrict javascript load in specific screens.

javascript should be load on create, edit and transition screens only for this,

what contexts need to use??

6 answers

1 accepted

0 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2013
The following is working for me
var transition=$("#issue-workflow-transition-submit").val();
  var editScreen=document.getElementById('edit-issue-submit');
  var issueType = AJS.$("#type-val").text();
  var issueTypeValue=$.trim(issueType);	
  if((transition=='Update by CCB'||editScreen!=null) && issueTypeValue == 'Defect'){		

//code here ..
}

Tayyab Bashir
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2016

Hi @Rambanam Prasad, 
I have to add add some javascript to workflow transitions as well,

Where do I have to put this code in the plugin? in atlassian-plugin.xml?  

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2016

Using webresource module we can add javascript, check the following doc for more information 

https://developer.atlassian.com/confdev/confluence-plugin-guide/writing-confluence-plugins/including-javascript-and-css-resources

if above link does't help then let me know!

Tayyab Bashir
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 27, 2016

Hi, 
Using the above link I added javascript that runs on atl.general pages.
But I need the JS to run on transition screens,
You have given some solution:

var transition=$("#issue-workflow-transition-submit").val();
  var editScreen=document.getElementById('edit-issue-submit');
  var issueType = AJS.$("#type-val").text();
  var issueTypeValue=$.trim(issueType);
  if((transition=='Update by CCB'||editScreen!=null) && issueTypeValue == 'Defect'){       
 
//code here ..
}

 
Where am I supposed to add this and how? Could you please tell me I would appreciate that very much.

I want my JS to run on all the issue transition windows for the permissible groups and for all the issue types.  

1 vote
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2012

You can let the context be atl.general and let your script decide when to execute

for example something similar to the below code :

if((AJS.$("#issue-create")||(AJS.$("#issue-edit")){

//your script

}

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2012

i am getting "Undefined" message,

i used following code

if(document.getElementById('edit-issue-submit') !=null || document.getElementById('issue-workflow-transition-submit') !=null || document.getElementById('create-issue-submit') !=null || document.getElementById('issue-create-submit') !=null){

//my JavaScript here
}

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2012

yes ur correct, but i am testing by giving just alerts

in transtion screens we can get issueid insted of pid

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2012

Does your js takes values from the document ? for example document.getElementById("pid") ?

bcoz pid is not available on transition screens . Even i had faced a similar problem, the js was not working on transition screen because i was trying to get pid

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2012

yes i seen this, but javascript should work on transition screens also :(

for you reference context for create screen is "jira.create.issue" not "jira.issue.create"(it won't work , tested on 5.0.3)

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2012

for create issue screen the context should be "jira.issue.create" This is available in 4.4 onwards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events