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 <noreply@anthropic.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-09-15 12:24:49 +01:00 committed by Pedro Amorim
parent d0a79a677c
commit 85c37deb77
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 4 additions and 0 deletions

View File

@ -1,6 +1,10 @@
// Bookings
var bookings_table;
$(document).ready(function () {
if (!$("#bookings_table").length) {
return;
}
const af = AdditionalFilters.init([
"filter-completed",
"filter-cancelled",