From bc66be24e49a882a4dfc7d396086fd97fbabd38b Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Fri, 15 Nov 2024 14:46:28 +0100
Subject: [PATCH] Bug 38436: Do not try to build the table if tab is not there

If we don't have the "other holdings" tab, no need to try to build the
table.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
---
 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
index b82e2213629..999258932b0 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -1982,6 +1982,10 @@
 
             let items_tab_ids = [ 'holdings', 'otherholdings' ];
             items_tab_ids.forEach( function( tab_id, index ) {
+
+                // Early return if the tab is not shown (ie. no table)
+                if (!$("#%s-tab".format(tab_id)).length) return;
+
                 build_items_table(tab_id, false, {}, build_items_table_drawncallback);
 
                 [% IF bundlesEnabled %]
-- 
2.34.1