feat: bootstrap htmx
This commit is contained in:
1 parent
60dfca1b64
commit
67875ccf10
1 file changed
+22
-7
+22
-7
@@ -1,10 +1,25 @@
|
||||
import './stimulus_bootstrap.js';
|
||||
/*
|
||||
* Welcome to your app's main JavaScript file!
|
||||
*
|
||||
* This file will be included onto the page via the importmap() Twig function,
|
||||
* which should already be in your base.html.twig.
|
||||
*/
|
||||
import './styles/app.css';
|
||||
|
||||
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
|
||||
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 },
|
||||
];
|
||||
Reference in new issue
Block a user