| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
(() => { |
| 10 |
let api; |
| 11 |
htmx.registerExtension('hx-prompt', { |
| 12 |
init(internalAPI) { api = internalAPI }, |
| 13 |
|
| 14 |
htmx_config_request(elt, {ctx}) { |
| 15 |
let question = api.attributeValue(ctx.sourceElement, 'hx-prompt'); |
| 16 |
if (question == null) return; |
| 17 |
let answer = (window.htmxPrompt || window.prompt)(question); |
| 18 |
if (answer === null) return false; |
| 19 |
if (!htmx.trigger(ctx.sourceElement, 'htmx:prompt', { prompt: answer, target: ctx.target })) return false; |
| 20 |
ctx.request.headers['HX-Prompt'] = encodeURI(answer); |
| 21 |
} |
| 22 |
}); |
| 23 |
})(); |