https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34907 --- Comment #2 from Brendan Lawlor <blawlor@clamsnet.org> --- (In reply to Jason Robb from comment #1)
We currently link in datatables via their cdn on custom OPAC pages where we want to neatly display public report data.
With the introduction of bug #38365 in 26.05, it sounds like that will break.
It would be nice to see this bug move along so we can leverage Koha's built-in datatables when building custom pages instead of relying on the external source.
I'm interested in how you're doing this now and how it works in general. I worked out a basic example you can copy and paste into an intranet page that doesn't use the cdn. It loads Koha's bundled datatables.js (in the example just replace intranet-tmpl with opac-tmpl for opac pages) I found that page.tt loads jquery in the footer, so any script embeded in the custom page runs before jquery is available. The trick is to add an event listener for DOMContentLoaded and then inject the datatables.js script in a script inside the head element. When that script loads initialize the datatable. This might be a workaround for your existing pages, and also may help with the enhancement to integrate datatables into Koha custom pages too :) code: <p>This page has a script to initialize a data table</p> <link href="/intranet-tmpl/lib/datatables/datatables.min.css" rel="stylesheet" /> <table id="example-dt" class="table"> <thead> <tr> <th>code</th> <th>data</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>123</td> </tr> <tr> <td>B</td> <td>42</td> </tr> <tr> <td>C</td> <td>999</td> </tr> <tr> <td>D</td> <td>67</td> </tr> </tbody> </table> <script> document.addEventListener('DOMContentLoaded', function () { var s = document.createElement('script'); s.src = '/intranet-tmpl/lib/datatables/datatables.min.js'; s.onload = function () { $('#example-dt').DataTable(); }; document.head.appendChild(s); }); </script> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.