From 6153c217419e0e6c3634d302874c484f390f0082 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 8 Jan 2024 16:56:06 +0000 Subject: [PATCH] Bug 35725: Fix 'Create' button enabled/disabled The previous patch fixed what it stated, but uncovered a new issue: If you input a cardnumber + a branchcode and then change type, the 'Create' button becomes disabled This happens because the trigger for it is on change only, the current patch updates this to also happen on DOMContentLoaded. Test plan: 1) Apply previous patch 2) Do steps from previous patch plan up to and including step 5) 3) Click 'Create'. Notice it doesn't submit (nothing happens). 4) Apply this patch and do a hard reload (clearing browser js cache) 5) Repeat steps 1) to 3). Notice it now submits correctly. Signed-off-by: David Nind --- Koha/ILL/Backend/intra-includes/create.inc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Koha/ILL/Backend/intra-includes/create.inc b/Koha/ILL/Backend/intra-includes/create.inc index 764013e1b9..2ebcc17b25 100644 --- a/Koha/ILL/Backend/intra-includes/create.inc +++ b/Koha/ILL/Backend/intra-includes/create.inc @@ -119,12 +119,18 @@ [% INCLUDE "${cwd}/shared-includes/shared.js" %] // Require a username and branch selection document.addEventListener('DOMContentLoaded', function(){ - $('#create_form #cardnumber, #create_form #branchcode').change(function() { - var comp = ['#cardnumber','#branchcode'].filter(function(id) { - return $(id).val().length > 0; - }); - $('#ill-submit').attr('disabled', comp.length < 2); + let cardnumber_input = '#create_form #cardnumber'; + let branchcode_input = '#create_form #branchcode'; + updateCreateButtonStatus(); + $(cardnumber_input + ',' + branchcode_input).change(function() { + updateCreateButtonStatus(); + }); + function updateCreateButtonStatus(){ + var comp = [cardnumber_input,branchcode_input].filter(function(id) { + return $(id).val().length > 0; }); + $('#ill-submit').attr('disabled', comp.length < 2); + } /* Maintain patron autocomplete compatibility across versions */ [% IF koha_version.major <= 22 && koha_version.minor < 11 %] $('#create_form #cardnumber').autocomplete({ -- 2.30.2