From 93f76211efd69d9405151b39258e4fea096c334e Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 28 Sep 2023 11:25:02 +0000
Subject: [PATCH] Bug 34944: Remove the use of event attributes from OPAC full
 serial issue page

This patch removes the use of event attributes (onclick) from the OPAC's
full serial issues template. These events are defined now along with the
other in-page JS.

To test you must have a serial record with issues from multiple years.

- Locate the serial record and view the detail page.
- Click "More details" at the bottom of the "Subscriptions" tab.
- Click the "Full history" tab.
- Test the "Show year" controls to confirm that clicking each year
  correctly filters the table of issues to show only issues from that
  year.
---
 .../bootstrap/en/modules/opac-full-serial-issues.tt        | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt
index 758dfcbeec..e644c9439c 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt
@@ -113,7 +113,7 @@
                             <strong>Show year: </strong>
                             [% FOREACH year IN years %]
                                 [% IF ( year.year ) %]
-                                    <a class="tabsubs" href="#" onclick="showlayer([% year.year | html %]); return false;">[% year.year | html %]</a>
+                                    <a class="tabsubs" href="#" data-year="[% year.year | html %]">[% year.year | html %]</a>
                                 [% END %]
                             [% END %]
                         </div>
@@ -200,9 +200,12 @@
             $("#reset").click(function(){
                 clearFilters();
             });
-            $("a.tabsubs").click(function(){
+            $("a.tabsubs").on("click", function(e){
+                e.preventDefault();
+                let year = $(this).data("year");
                 $("a.tabsubs").removeClass("currentsubtab");
                 $(this).addClass("currentsubtab");
+                showlayer( year );
             });
             $(".subscriptionstclass").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "order": [[ 0, "desc" ]]
-- 
2.30.2