diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index a4c8be52..af991c2c 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -341,6 +341,26 @@ function loadJsonToolStateOnCurrentImage(element, json) { } +// Called by HTMX after a fragment swap; initializes any dicom-image-legacy viewers +window.initAnatomyFragment = function(fragmentRoot) { + try { + // If a fragment root is an element (hx-on passes `this`), search within it. + const root = fragmentRoot || document; + const imgs = (root.querySelectorAll) ? root.querySelectorAll('.dicom-image-legacy') : []; + imgs.forEach((el) => { + try { + if (typeof window.setUpDicomLegacy === 'function') { + window.setUpDicomLegacy(el); + } + } catch (err) { + console.warn('initAnatomyFragment: setUpDicomLegacy failed for element', el, err); + } + }); + } catch (err) { + console.warn('initAnatomyFragment error', err); + } +} + async function setUpDicomLegacy(element) { console.log("setUpDicom (original)", element); diff --git a/anatomy/templates/anatomy/partials/exam_review_question_fragment.html b/anatomy/templates/anatomy/partials/exam_review_question_fragment.html index 603a4de8..62bb401d 100644 --- a/anatomy/templates/anatomy/partials/exam_review_question_fragment.html +++ b/anatomy/templates/anatomy/partials/exam_review_question_fragment.html @@ -1,4 +1,4 @@ -
{{ question.question_type }}