25 lines
766 B
JavaScript
25 lines
766 B
JavaScript
import './bootstrap.js'
|
|
import './loading.js'
|
|
|
|
import './styles/app.css'
|
|
|
|
import htmx from 'htmx.org'
|
|
|
|
window.htmx = htmx
|
|
htmx.config.includeIndicatorStyles = false
|
|
htmx.config.historyEnabled = true
|
|
htmx.config.historyCacheSize = 10
|
|
htmx.config.allowScriptTags = false
|
|
htmx.config.withCredentials = true
|
|
htmx.config.selfRequestsOnly = false
|
|
htmx.config.timeout = 50000 // 50 seconds - slightly higher than backend timeout (45s)
|
|
|
|
document.body.addEventListener('htmx:beforeSwap', (event) => {
|
|
// Symfony renders invalid forms with 422; let HTMX swap those responses so inline
|
|
// validation errors are actually shown to the user.
|
|
if (event.detail?.xhr?.status === 422) {
|
|
event.detail.shouldSwap = true
|
|
event.detail.isError = false
|
|
}
|
|
})
|