{# ========================================================================= Shared confirm-dialog macro. Renders the DaisyUI that /ui/js/confirm.js drives, plus the (cache-busted, deferred) script tag itself. Call it ONCE per page, in the page's scripts block: {% from "macros/confirm.html" import confirm_dialog %} {% block page_scripts %}{{ confirm_dialog() }}{% endblock %} Then put data-confirm="Prompt text" on any
, or on the submit button whose click needs its own wording. HTMX-driven forms (hx-* on the ) must carry the prompt on the FORM — htmx:confirm only sees the element issuing the request, so a prompt on a descendant button would silently never fire. See confirm.js for the full contract. Never use bare confirm() (unstyled, unthemed) or inline onclick= handlers (JS context that autoescape cannot protect) — this macro is the ecosystem's single confirmation mechanism. Parameters ---------- title : str — dialog heading (default 'Are you sure?'). ok_label : str — confirm-button text (default 'Yes, do it'). cancel_label : str — cancel-button text (default 'Cancel'). ok_class : str — DaisyUI variant for the confirm button (default 'btn-primary'; destructive pages pass 'btn-error'). ========================================================================= #} {% macro confirm_dialog(title='Are you sure?', ok_label='Yes, do it', cancel_label='Cancel', ok_class='btn-primary') %} {# DaisyUI backdrop-close: clicking outside the modal-box submits this dialog-method form, which closes the dialog and fires the same `close` event the cancel path uses — confirm.js clears its pending state. #}
{% endmacro %}