Files
ephub/assets/app.js
T
2026-09-13 14:14:41 +02:00

26 lines
1.1 KiB
JavaScript

import './stimulus_bootstrap.js';
import './styles/app.css';
import htmx from 'htmx.org';
// Exposed so inline `hx-on:` handlers and Stimulus controllers can reach htmx.
window.htmx = htmx;
// We never return <script> tags in fragments; refuse to run them if one slips through.
htmx.config.allowScriptTags = false;
// Indicators are styled in Tailwind, not by htmx's injected <style> block.
htmx.config.includeIndicatorStyles = false;
// AbstractController::render() returns 422 when it is handed an invalid submitted form, and
// htmx 2 does not swap 4xx by default -- so without this entry a failed validation would
// silently do nothing and the modal would just sit there unchanged.
// resolveResponseHandling() returns the FIRST matching entry, so 422 must precede the
// [45].. catch-all. The other three entries are htmx's defaults, repeated because assigning
// this config replaces the whole array.
htmx.config.responseHandling = [
{ code: '204', swap: false },
{ code: '[23]..', swap: true },
{ code: '422', swap: true, error: false },
{ code: '[45]..', swap: false, error: true },
];