Module

server.delegation

Event delegation for dynamic content (SSE, OOB, fragments).

hx-onis bound at parse time; content swapped by htmx (SSE, OOB, fragments) does not get new handlers. This script uses event delegation ondocumentso handlers work for dynamically inserted elements.

Handles:

  • .copy-btn — copies text from ancestor [data-copy-text]to clipboard
  • .compare-switch — toggles aria-checked and syncs input[name=compare], select[name=model_b]in the same form

Injected into full-page HTML responses viaHTMLInjectmiddleware. Controlled byAppConfig(delegation=True) (default: False).