From b079526c469bf0cc1620d011373d5a00b75c723a Mon Sep 17 00:00:00 2001
From: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Date: Fri, 25 Oct 2024 15:31:42 +0000
Subject: [PATCH] Bug 38275: Ensure that the script block is loaded after the
 HTML elements are available.

Signed-off-by: David Nind <david@davidnind.com>
---
 .../en/modules/patroncards/image-manage.tt    | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt
index 73d6aff04a..d83f497f42 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt
@@ -131,7 +131,7 @@
                                     <h3>Image(s) successfully deleted</h3>
                                 </div>
                                 [% END %]
-                            </fieldset>
+                            </field
                             <fieldset class="action">
                                 <input type="hidden" name="op" value="cud-delete" />
                                 <input class="btn btn-primary" type="button" id="delete" value="Delete selected" />
@@ -164,6 +164,16 @@
 
 [% MACRO jsinclude BLOCK %]
     <script>
+
+        $(document).ready(function() {
+            $("#delete").click(function(){
+                return DeleteConfirm();
+            });
+            $(".delete_image").on("click", function(){
+                return confirmDelete( _("Are you sure you want to delete this image?") );
+            });
+        });
+
         function DeleteConfirm() {
             var results = selected_images("delete");
             if (results.images) {
@@ -197,14 +207,6 @@
             }
             return (-1);
         }
-        $(document).ready(function() {
-            $("#delete").click(function(){
-                return DeleteConfirm();
-            });
-            $(".delete_image").on("click", function(){
-                return confirmDelete( _("Are you sure you want to delete this image?") );
-            });
-        });
     </script>
 [% END %]
 
-- 
2.39.5