This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
htmx.config.useTemplateFragments = true | |
htmx.defineExtension('clone', { | |
onEvent: function (name, evt) { | |
if (name === 'htmx:beforeRequest') { | |
if (evt.detail.elt) { | |
const get = evt.detail.elt.getAttribute('hx-get') | |
if (get && get.startsWith('clone:')) { | |
const selector = get.substring(6) | |
//console.log('htmx-clone: Intercepting xhr request to inject template with selector:', selector) | |
const template = document.querySelector(selector) |