1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-12-02 03:24:46 +01:00

Solve bug in search

This commit is contained in:
Maxime JUST
2025-12-01 19:06:57 +01:00
parent 3666a85a52
commit 1f10a2bfae

View File

@@ -4,9 +4,9 @@ function initModal(target, url, content_id = 'form-content', always_refetch = fa
let modalBody = document.querySelector("#" + target + "Modal div.modal-body")
if (!modalBody.innerHTML.trim() || always_refetch) {
if (url instanceof Function) url = url()
let finalUrl = (url instanceof Function ? url() : url);
fetch(url, {headers: {'CONTENT-ONLY': '1'}})
fetch(finalUrl, {headers: {'CONTENT-ONLY': '1'}})
.then(resp => resp.text())
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)