Skip to content

Commit eb1d140

Browse files
committed
Add HTMX afterSwap event function calls
Signed-off-by: tdruez <[email protected]>
1 parent a0b728a commit eb1d140

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

scancodeio/static/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,14 @@ document.addEventListener('DOMContentLoaded', function () {
463463

464464
});
465465

466+
// HTMX
467+
468+
document.body.addEventListener("htmx:afterSwap", function(evt) {
469+
// Call the following functions after a HTMX swap is done.
470+
setupTabs();
471+
enableCopyToClipboard(".copy-to-clipboard");
472+
});
473+
466474
// Toasts (requires bulma-toast.js)
467475

468476
function displayPipelineStatusToast(run_status, pipeline_name, project_url) {

scanpipe/templates/scanpipe/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link rel="stylesheet" href="{% static 'main.css' %}" crossorigin="anonymous">
1313
{% block extrahead %}{% endblock %}
1414
</head>
15-
<body class="pb-5">
15+
<body class="pb-5" hx-headers='{"x-csrftoken": "{{ csrf_token }}"}'>
1616
{% block content %}{% endblock %}
1717
{% include 'scanpipe/modals/search_syntax_modal.html' %}
1818
<script src="{% static 'main.js' %}" crossorigin="anonymous"></script>

scanpipe/templates/scanpipe/resource_tree.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737

3838
{% block scripts %}
3939
<script>
40-
document.body.addEventListener('htmx:afterSettle', function(evt) {
41-
if (typeof enableCopyToClipboard === 'function') {
42-
enableCopyToClipboard('.copy-to-clipboard');
43-
}
44-
});
45-
4640
async function toggleFolderNode(folderNode, forceExpand = false) {
4741
const targetId = folderNode.dataset.target;
4842
const url = folderNode.dataset.url;

0 commit comments

Comments
 (0)