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

    high-microphone-71328

    05/10/2023, 1:25 PM
    worked! thanks
  • m

    mysterious-toddler-20573

    05/10/2023, 1:29 PM
    🤝
  • h

    high-microphone-71328

    05/10/2023, 3:41 PM
    posted the script.
  • h

    high-microphone-71328

    05/10/2023, 3:41 PM
    in a thread
  • p

    proud-librarian-99598

    05/10/2023, 6:20 PM
    I am playing with having form validation errors coming "live" from my backend. For this, I added an extra GET endpoint which will return the
    <form>
    with the validation errors in it if there are. To make this work, I have to repeat the same
    hx-get
    on each input field since it is not an element that inherits. I would liked to have just put it on the
    <form>
    once. Is this just the way it is, or are there alternatives I can use?
  • h

    high-microphone-71328

    05/10/2023, 6:24 PM
    can't you just replace the whole form?
  • p

    proud-librarian-99598

    05/10/2023, 6:28 PM
    I want the htmx request to trigger on
    keyup changed throttle:200ms
    for the inputs in the form. If I add
    hx-get
    just on the form, no request is sent. I need to add the
    hx-get
    on the
    <input>
    itself.
  • h

    high-microphone-71328

    05/10/2023, 6:31 PM
    Oh so your issue is not issuing a bunch of requests each time but rather having to put the hx-get everywhere?
  • p

    proud-librarian-99598

    05/10/2023, 6:32 PM
    Indeed
  • h

    high-microphone-71328

    05/10/2023, 6:33 PM
    you might be able to add a modifier to
    keyup changed throttle:200ms
    . https://htmx.org/docs/#trigger-modifiers
  • h

    high-microphone-71328

    05/10/2023, 6:52 PM
    New Question: is there a way yet to download a response from an htmx response? like if the headers are
    content-disposition: attachment; filename=private.file
  • g

    great-cartoon-12331

    05/10/2023, 6:56 PM
    afaik, no
  • m

    mysterious-toddler-20573

    05/10/2023, 7:08 PM
    no
  • m

    mysterious-toddler-20573

    05/10/2023, 7:08 PM
    best option is a client-side redirect to that URL
  • m

    mysterious-toddler-20573

    05/10/2023, 7:09 PM
    did you put the
    keyup
    trigger on the form too?
  • h

    high-microphone-71328

    05/10/2023, 7:10 PM
    what are the disadvantages of this function?
    Copy code
    const downloadCSVfromJsonResponse = (file) => {
        let blob = new Blob([file.body], { type: file.type })
        const DownloadUrl = URL.createObjectURL(blob)
        const anchorElement = document.createElement('a')
        anchorElement.href = DownloadUrl
        anchorElement.download = `${file.name}`
        anchorElement.click()
        anchorElement.parentNode.removeChild(anchorElement)
        URL.revokeObjectURL(DownloadUrl)
    }
  • h

    high-microphone-71328

    05/10/2023, 7:10 PM
    it does everything client side
  • p

    proud-librarian-99598

    05/10/2023, 7:11 PM
    Just tried it now, makes no difference it seems.
  • m

    mysterious-toddler-20573

    05/10/2023, 7:11 PM
    I don't see a big one, other than htmx doesn't do that 🙂
  • m

    mysterious-toddler-20573

    05/10/2023, 7:11 PM
    might be a good feature to add
  • h

    high-microphone-71328

    05/10/2023, 7:12 PM
    I'm gonna implement it now and post a function
  • m

    mysterious-toddler-20573

    05/10/2023, 7:13 PM
    hmm,
    keyup
    should bubble
  • m

    mysterious-toddler-20573

    05/10/2023, 7:13 PM
    can you debug it?
  • m

    mysterious-toddler-20573

    05/10/2023, 7:13 PM
    https://htmx.org/docs#debugging
  • h

    high-microphone-71328

    05/10/2023, 7:14 PM
    that function expects a very specific object. so I'll rewrite it to work a little more like the browser.
  • p

    proud-librarian-99598

    05/10/2023, 7:17 PM
    monitorEvents(htmx.find("form"));
    does indeed show
    keyup
    events coming from my input. But
    htmx.logAll();
    is not printing anything and I see no request happening. I'll try to build a small example later, getting late here now.
  • m

    mysterious-toddler-20573

    05/10/2023, 7:33 PM
    roger, will have more time to help tomorrow
  • m

    mysterious-toddler-20573

    05/10/2023, 7:36 PM
    "HYPERMEDIA ON WHATEVER YOU'D LIKE" he screamed, out loud, scaring his dogs #1105940759556923433
  • f

    few-parrot-58207

    05/10/2023, 8:09 PM
    can htmx run on a teapot? There's a nice http code for that…
  • h

    high-microphone-71328

    05/10/2023, 8:16 PM
    when intercepting the "htmx:afterOnLoad" event, can I change the swap behavior? (wanna change it to none)
1...112111221123...1146Latest