From 85c37deb774d151e673f3f179daf5194510c798d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 15 Sep 2026 12:24:49 +0100 Subject: [PATCH] Bug 41898: (follow-up) Guard bookings.js against missing DOM when patron has no bookings js/tables/bookings.js unconditionally called AdditionalFilters.init() for 'filter-completed' and 'filter-cancelled' on every page load where the script is included. patron-detail-tabs.inc only renders those filter elements (and #bookings_table itself) when the patron has at least one booking, past or present. For any patron with no booking history, this produced two console.debug 'Element not found' messages on moremember.pl and circ/circulation.pl. Guard the ready handler on the presence of #bookings_table, mirroring the existing pattern in holds.js. Test plan: 1) Open moremember.pl for a patron with no bookings; confirm no AdditionalFilters console messages appear. 2) Open moremember.pl / circ/circulation.pl for a patron with bookings; confirm the Bookings tab, filters, and table still work as before. Co-Authored-By: Claude Sonnet 5 Signed-off-by: Pedro Amorim --- koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js b/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js index 7cac45d9d1..79ae5fc433 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js +++ b/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js @@ -1,6 +1,10 @@ // Bookings var bookings_table; $(document).ready(function () { + if (!$("#bookings_table").length) { + return; + } + const af = AdditionalFilters.init([ "filter-completed", "filter-cancelled",