https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • s

    square-analyst-94375

    01/26/2023, 3:31 AM
    @mysterious-toddler-20573 There is a bug in htmx/demo.htmx.org You can see it in action here: https://codepen.io/checketts/pen/bGjMBeP?editors=1001 In debugging, I see that the XHR.onload is getting called twice by the mock-requests (not sure why), so the first call works (swapping the element), but the second call tries to swap the outerHTML, but at this point the element is no longer in the DOM and can't be swapped by its outerHTML. In issueAjaxRequest:2644 it check if the element is in the body and returns if it isn't. Perhaps that guard also should exist in the
    onload
    around line 2882.
  • b

    bumpy-kangaroo-60192

    01/26/2023, 6:01 AM
    Just deleted 530 lines of javascript ๐Ÿ™‚
  • a

    adventurous-ocean-93733

    01/26/2023, 6:29 AM
    Didnโ€™t realise
    enterKey
    was recognised, Iโ€™ve used
    keyup[key=='Enter']
  • b

    busy-action-85810

    01/26/2023, 2:59 PM
    Thanks but I'm afraid that doesn't work either. It seems once I start clicking around or using the DELETE, arrow keys, etc. HTMX triggers regardless and sends the HTTP PATCH request. Maybe I need to do something in addition to just listening for the specific key event?
  • m

    mysterious-toddler-20573

    01/26/2023, 3:31 PM
    https://codepen.io/1cg/pen/BaPxGER
  • m

    mysterious-toddler-20573

    01/26/2023, 3:31 PM
    This works for me @busy-action-85810 ๐Ÿ‘†
  • m

    mysterious-toddler-20573

    01/26/2023, 3:32 PM
    if the input is in a form it may be triggering a non-htmx request on the form, you'll need to catch the event and prevent the default action from happening
  • a

    adventurous-ocean-93733

    01/26/2023, 3:44 PM
    Was also playing with this example when 1cg submitted the above, in case it helps: https://codepen.io/elliottinvent/pen/PoBeXom
  • a

    ancient-shoe-86801

    01/26/2023, 5:17 PM
    HTMX gets mentioned here, from what I see on the episode notes: https://changelog.com/jsparty/258
  • a

    ancient-shoe-86801

    01/26/2023, 5:17 PM
    haven't listened to it yet
  • m

    mysterious-toddler-20573

    01/26/2023, 5:59 PM
    https://twitter.com/htmx_org/status/1618651534895771649
  • h

    hundreds-cartoon-20446

    01/26/2023, 6:27 PM
    HTMX also got covered in this talk by John D Wells at Craft's Dot All conference last year: https://craftcms.com/events/dot-all-2022/sessions/a-practical-guide-to-html-over-the-wire
  • e

    early-camera-41285

    01/26/2023, 8:34 PM
    I love locality of behavior. but. Is there a way to wire up a very long form to submit on a change in any input without explicitly adding an
    hx-trigger
    to every input? I could do that, but I'm wondering if there is a way to do it on the
    <form/>
    element instead.
  • m

    mysterious-toddler-20573

    01/26/2023, 8:48 PM
    hx-trigger='input'
    on the form should work, the event will bubble up to it
  • b

    blue-gold-89534

    01/26/2023, 9:40 PM
    is this behaviour covered in any of the examples? I kind of missed that in this explicity. Would not hurt to have a bigger form example than https://htmx.org/examples/edit-row/ maybe where this is promoted?
  • r

    ripe-action-67367

    01/26/2023, 9:48 PM
    https://htmx.org/docs/#inheritance
  • p

    prehistoric-garden-45720

    01/26/2023, 9:48 PM
    I've used
    keydown[key=='Enter'&&!shiftKey]
    to trigger in a text area when Enter without the SHIFT key is pressed, so
    keyup[key=='Enter']
    should work. I think
    enterKey
    didn't work for me.
  • a

    astonishing-teacher-48635

    01/27/2023, 12:58 AM
    Copy code
    htmx.on('htmx:responseError', function(evt) {
    is there a way to retry evt.detail.xhr inside this event?
  • b

    busy-action-85810

    01/27/2023, 12:58 AM
    Thanks. That works for me too. I'm wondering if the problem I'm experiencing has to do with the way I first click on the
    <span>
    to trigger HTMX to load the
    <input>
    which, once swapped, then listens for the
    Enter
    keyup event. In case it helps, here's the source code (using ERB) to first render the "task" partial: https://github.com/bkuhlmann/hemo/blob/main/slices/main/templates/tasks/_task.html.erb#L10 ...and here is "edit" template what is swapped in which then listens for the
    Enter
    keyup event: https://github.com/bkuhlmann/hemo/blob/main/slices/main/templates/tasks/edit.html.erb#L20-L26
    a
    m
    • 3
    • 22
  • m

    mysterious-toddler-20573

    01/27/2023, 3:23 AM
    not that I am aware of, but there probably should be!
  • b

    brainy-zoo-88281

    01/27/2023, 9:14 PM
    Hi, What's your approach when trying to add something like google maps to your app? I'm struggling with figuring out how to add a script and init function that will work and not load it on all requests to the page with a map.
  • g

    gentle-salesclerk-37089

    01/27/2023, 9:43 PM
    sorry if im missing it, but is there any technique for smoothly handling an error when the server is offline?
  • g

    gentle-salesclerk-37089

    01/27/2023, 9:43 PM
    like having some html ready in page for a true 500
  • b

    big-airline-13935

    01/28/2023, 2:29 AM
    My favourite part is when @mysterious-toddler-20573 is called a "mad scientist" at minute 19:45 ๐Ÿ˜‚
  • m

    mysterious-toddler-20573

    01/28/2023, 3:12 AM
    can you host the map in one section and target requests for another section so the map stays unchanged?
  • r

    refined-pillow-25368

    01/28/2023, 12:52 PM
    How would you guys handle a debounce on a form submit? Kinda seems like something that html should offer
  • b

    bland-coat-6833

    01/28/2023, 1:59 PM
    use the
    delay
    modifier on
    hx-trigger
  • r

    refined-pillow-25368

    01/28/2023, 2:13 PM
    thanks
  • r

    refined-pillow-25368

    01/28/2023, 2:16 PM
    But I want to have the debounce after the first click
  • r

    refined-pillow-25368

    01/28/2023, 2:16 PM
    if I put hx-trigger="submit delay:5000ms"
1...9989991000...1146Latest