Need to hide a checkbox field

UDAYARANGA MUDIGERE January 15, 2016

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>

4 answers

0 votes
UDAYARANGA MUDIGERE January 18, 2016

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2016

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.

0 votes
UDAYARANGA MUDIGERE January 18, 2016

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2016

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events