I have a Single Choice select list (Environment) and two check boxes (Norman Privileges and Admin Privileges). Currently I want to show Admin Privileges only if Production from Environment dropdown is selected. Otherwise it should hide that field. I am trying this script and it is not hiding the field. Could you please let me know if I am doing anything wrong here?
<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
callChangeFunction();
});
callChangeFunction();
function callChangeFunction() {
showHideField();
$("#customfield_12440").change(function() {
showHideField();
});
}
function showHideField() {
var environment = $.trim($("#customfield_12440 :selected").text());
$("#customfield_16144").parent().hide();
if (environment == 'Production') {
$("#customfield_16144").parent().show();
}
if (environment == 'Non-Production') {
$("#customfield_16144").parent().hide();
}
}
});
</script>
NIC:
whenever I was selecting Non-Production, Admin Privileges field was hiding. When I removed the JavaScript on the Admin Privileges field, cleared the browser cache and restarted JIRA, the field is still hiding when Non-Production field is being selected. This is what was happening.
Udaya
I don't think so, your browser probably cached some javascript that has now been cleared out. You've not described what is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nic:
Thank you for replying. I got this script to work and it is working fine right now. The field gets hidden upon selecting a value in the dropdown. I had one change to make and removed the javascript. I thought the field will not get hidden and it is still hiding the field even after removing the script. I removed the internet cache, restarted JIRA and still the same. Is there any issue?
Udaya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's a really easy answer to "what is being done wrong" - it's "using javascript in JIRA"
Technically, I don't think there is anything really wrong with your code, other than the .parent calls might not be quite right, and I'm not sure what version of jquery/JIRA you're aiming for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.