| 1 | // After morph navigation: re-init hyperscript. |
| 2 | (function () { |
| 3 | document.addEventListener('htmx:before:swap', function (e) { |
| 4 | if (e.detail?.ctx?.target !== document.body) return; |
| 5 | // Invalidate any pending server.start() promise from the previous page |
| 6 | window._demoGeneration = (window._demoGeneration || 0) + 1; |
| 7 | // Clear routes so old handlers can't respond to new page's requests |
| 8 | if (window.server) window.server.reset?.(); |
| 9 | }); |
| 10 | |
| 11 | document.addEventListener('htmx:after:swap', function (e) { |
| 12 | if (e.detail?.ctx?.target !== document.body) return; |
| 13 | if (window._hyperscript) window._hyperscript.processNode(document.body); |
| 14 | }); |
| 15 | })(); |