colossal-engine-30767
03/04/2023, 7:54 PMflat-vase-53984
03/04/2023, 8:14 PMbland-coat-6833
03/04/2023, 8:26 PMripe-action-67367
03/04/2023, 9:09 PMhx-vals="js:
attribute.
https://htmx.org/extensions/web-sockets/#htmx:wsConfigSend
https://htmx.org/attributes/hx-vals/limited-teacher-83117
03/04/2023, 10:51 PMxxx-www-form-urlecoded
instead of JSON forms is another). HTMX provides affordances like hx-vals
or events to accommodate more complex logic or less flexible systems, but the more you can use defaults the more you're letting other people's optimized systems do the worknutritious-architect-21200
03/05/2023, 1:57 PMrapid-umbrella-80895
03/05/2023, 2:20 PMmysterious-toddler-20573
03/05/2023, 2:43 PMnutritious-architect-21200
03/05/2023, 2:52 PMmysterious-toddler-20573
03/05/2023, 2:54 PMmysterious-toddler-20573
03/05/2023, 2:56 PMhtml
<a href="#"
_="on click
fetch {% text_hx_sample %} then
put the result into the #suggested_value's value">Get New Value</a>
mysterious-toddler-20573
03/05/2023, 2:57 PMmysterious-toddler-20573
03/05/2023, 2:57 PMmysterious-toddler-20573
03/05/2023, 2:57 PMrapid-umbrella-80895
03/05/2023, 3:03 PMbitter-carpet-58319
03/05/2023, 5:55 PMadventurous-ocean-93733
03/05/2023, 8:11 PMgreat-gold-37694
03/05/2023, 8:17 PMenough-petabyte-50314
03/05/2023, 11:20 PMbitter-carpet-58319
03/05/2023, 11:24 PMbitter-carpet-58319
03/05/2023, 11:25 PMmysterious-toddler-20573
03/05/2023, 11:59 PMmammoth-family-48524
03/06/2023, 4:38 AMhtmx.js:1845 TypeError: Cannot read properties of null (reading 'focus')
because the component isn't loaded before htmx tries to set the focus.
The Shoelace developer suggested using await customElements.whenDefined('sl-button')
.
I've managed to avoid async stuff thus far so I'm a bit out of my depth. This was my attempt (which didn't work).
html
document.body.addEventListener('htmx:beforeSwap', async function removePlaceholder(evt) {
const undefinedElements = evt.detail.target.querySelectorAll(":not(:defined)")
console.log(undefinedElements)
const promises = [...undefinedElements].map((el) =>
customElements.whenDefined(el.localName)
);
// Wait for all the children to be upgraded
await Promise.all(promises);
})
calm-parrot-34414
03/06/2023, 8:28 AMmammoth-family-48524
03/06/2023, 8:38 AMfreezing-waitress-26396
03/06/2023, 8:42 AMmammoth-family-48524
03/06/2023, 8:58 AMjavascript
console.log("About to add a listener for htmx:swapError...")
document.body.addEventListener('htmx:swapError', function(evt) {
console.log(evt)
})
mammoth-family-48524
03/06/2023, 8:59 AMAbout to add a listener for htmx:swapError...
htmx.js:1875 htmx:swapError
calm-parrot-34414
03/06/2023, 9:02 AMfreezing-waitress-26396
03/06/2023, 9:31 AM"put a <script> link to htmx.js into your HTML and go"
, without having to touch any existing build- or development infrastructure