I tried to add some JavaScript inside a custom field description and it worked well inside the custom field editor.
Still, it seems that Jira stripped my javascript from the description when it was displayed in the issue UI (as apposed to the admin area, where it did not).
So, I would say this is a bug, now the question is how to workaround this and have my code executed.
In complement to my previous intervention, I have just found how a workaround to my issue:
<script type="text/javascript"> (function($) { AJS.toInit(function(){ do stuff... }); JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { do stuff again... }); // ------------------ Below the new line $(selector_of_the_element_to_modify).live("click", do stuff agin...) })(AJS.$); </script>
I thought the .live would be sufficient, but the rest of the code provided by John Burns is still required: the call to .toInit and .bind handles the case when the create popup opens with the CF already shown, and the call to .live handles the case when the project/issue type needs to be changed to display the CF
Not sure how this can be used to do something else than adding handlers to specific elements, though
Try using this template:
<script type="text/javascript"> (function($) { AJS.toInit(function(){ do stuff... }); JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { do stuff again... }); })(AJS.$); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried and the code does not reach the UI or Create/Edit issue. Still, anything that is outside the script tags does reach. Are you sure that you tested this with Jira 5.2?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I am on 5.2, and it works in my instance. You might need to open a support ticket on this one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am retrying now on a test instance by enabling the safe mode, maybe there is somethiing that does this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
John's answer worked for my case (Jira 5.0.7, trying to set onclick actions for a CF), thank you very much John !
Still there is a case when it is not enough: my CF is only available for one issue type (New feature). When the Create popup opens with another issue type selected and I change it to New Feature, the script seems not to run. Not a real problem for my case, I'll eventually try to find a workaround
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
did you find a workaround? I have currently the exactly same issue and for me it _is_ a problem ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you included it in the correct field configuration? Editing description under custom fields is not enough.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it should be enough, as the description I entered does appear inside the Create/Edit screen, it is updated when I modify it but it does not contain the script part `<script>...</script>`. Which, by the way is included in the list of custom fields in the admin. I think this is related to the fact that in new jira (5.x), the Create/Edit screens are created from JSON instead of being rendered on the server side.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try adding it in the field configuration and see how it works? I can certainly find mine in the create/edit screens. Even on Create/Edit, rendering is done on server side.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried, no change the script section is removed but the rest is kept.
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.