Issue description onload

srinivasp
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.
February 6, 2012

In jira 4.0.2, we have a js file that is called on load of issuesummary.jsp file to do some specific operations on the description section of issue. I tried the same in jira 4.4.4 by inlucding the js statements in issuesummary.jsp file but it is not working. Can you please suggest what needs to update in order to call that js from that jsp file?

Thanks in Advance.. Srinivas

1 answer

1 accepted

0 votes
Answer accepted
Dieter
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.
February 7, 2012

Hi Srinivas,

I'm afraid the JS is put a in place where the DOM tree has not been load yet. I suggest you to put the code into a document ready handler like in this snippet

<script>
(function($){
   $(document).ready(function(){
         // do something with description field
   });  
})(AJS.$);
</script>

I'd also recommend to avoid changing system jsp's but put this code into the description of the system field 'description'. Use your own field configuration (scheme) for that. That way JIRA updates are with less effort for you.

Dieter

srinivasp
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.
February 7, 2012

Hi Dieter,

Thanks for your reply but i treid other way. I included the js script tag in header.jsp file and then it worked. As the other pages also got effected, i removed the script tag from the header.jsp and added it to issuesummaryblock.vm file since i want the js function to be called only on the onload of issue summary view. It is working now as required :)

Do you suggest any other way for handling this requirement?

-Srinivas

Dieter
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.
February 7, 2012
Hi Srinivas, The solution i described would be called only when the description is edited or created. In this case the description of a field is displayed and thus the JS is executed. But i see now that this does not help when you just view the issue. In this case the description of a field is not displayed and thus the JS script is not executed. This could be solved by putting the above code in the system banner and doing a quick check if a field with id description exists. This should not harm performance and usually one eill put more and more jacascript beautifiieing code in the system banner, also because it can be tested easily. Regards, dieter
Dieter
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.
February 7, 2012
Sorry for the bad formatting, this is what aac creates of text inputted on an ipad ;)
srinivasp
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.
February 7, 2012

Hi Dieter, If i add the code to the system banner, it will work but the javascript will be executed on the onload of all pages which may cause disturbance to other pages. The reason because the javascript is executing during the issue edit also which is not actually required. Hence i added to issuesummaryblock.vm file.

Dieter
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.
February 8, 2012
Dieter
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.
February 8, 2012
Hi srinivas, you could also put the JS code in a web resource plugin module and specify a web resource context for the view issue page. In this case you the code would also be loaded when you view an issue. I guess this approach is even better than put it in the system banner but requires you to learn about about the SDK. regards, dieter
srinivasp
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.
February 8, 2012

Yes. Even i thought of configruing a web-resource plugin module but it is strange that even with a simple html script tag i am able to access the javascript file. Since my purpose of execution of js on the onload of vm file is solved, i am continuing with the same solution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events