Dynamically shown/hidden fields are always visible after issue type was switched in create issue window

Bernd October 3, 2012

Hi,

we use the follwing code in the description (field configuration) of a text field to show or hide the field depending on a certain selection in another field (combobox):

<script type="text/javascript">
	affBuild = document.getElementById('customfield_10120');
	if (affBuild) {
		affSpecBuild = document.getElementById('customfield_10321');
		affSpecBuildParent = affSpecBuild.parentNode;
				
		if (affBuild.value != '10312') {
			affSpecBuildParent.style.display ='none';
			affSpecBuild.value = '';
		}
 
		affBuild.onchange=function() {
		if (this.value == '10312') {
			affSpecBuildParent.style.display = '';
		} else {
			affSpecBuildParent.style.display ='none';
			affSpecBuild.value = '';
		}
	}
}
</script>

With JIRA 5.X it is possible to switch the issue type in the "create issue" screen. After the switch was performed the script is no longer working (is not even called anymore as I have checked by setting "alert()" to the hide/show cases) and the field is always shown.

Do you know a way to keep the code functional after such a switch?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Harry Chan
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.
October 4, 2012

Hi, in JIRA 5.x, you need to do something like:

&lt;script type="text/javascript"&gt;
function task() {
}
task();
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
  task();
});
&lt;/script&gt;

Bernd October 9, 2012

Thank you this works fine.

TAGS
AUG Leaders

Atlassian Community Events