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

    handsome-gpu-11538

    07/27/2022, 4:25 AM
    however, i allow the users to add notes to their responses, and these notes are all edited with a single modal dialog div that i overlay on the page while they are editing it.
  • h

    handsome-gpu-11538

    07/27/2022, 4:26 AM
    to get this to function correctly, on that modal div, I do a "modalForm.setAttribute('hx-target' and 'hx-select' in the modal dialog's show eventlistener
  • h

    handsome-gpu-11538

    07/27/2022, 4:26 AM
    in a standard flow, it works great.
  • h

    handsome-gpu-11538

    07/27/2022, 4:27 AM
    however, i have discovered that if the user brings up the modal dialog again for a different div id, while the original one is still htmx processing, it somewhat silently breaks the htmx response.
  • h

    handsome-gpu-11538

    07/27/2022, 4:28 AM
    in the normal flow, after the final "beforeCleanupElement" event, i get an afterSwap.
  • h

    handsome-gpu-11538

    07/27/2022, 4:29 AM
    in the simultaneous flow, it jumps to the afterRequest, and somehow the hx-target and hx-select are already updated to the new IDs.
  • h

    handsome-gpu-11538

    07/27/2022, 4:31 AM
    is htmx actually processing the post to the form by still reading the document's form? All of those values that are submitted in the post are not "locked" during the duration of the post?
  • h

    handsome-gpu-11538

    07/27/2022, 4:35 AM
    actually looking closer at the logs, i can even see when the form changes during the xhr:progress duration.
  • h

    handsome-gpu-11538

    07/27/2022, 4:36 AM
    at one point the hx-target is "#response_185", and then the next progress event it is "#response_192"...
  • b

    bitter-monkey-50309

    07/27/2022, 10:24 AM
    Could you keep the modal on screen until the htmx request has completed? I've got some events on my modals that submit forms where the buttons in the footer are disabled when a request is inflight and only if it's completed successfully does the modal close, that way I can rerender the form with any errors returned from the server, or if its a network error, reenable the button with a toast that something unexpected went wrong and to retry in a moment. That way I can be sure that if something goes wrong the user doesn't lose their form input.
  • g

    gorgeous-ghost-95789

    07/27/2022, 2:02 PM
    This is the way. Just set up your server to include an
    HX-Trigger
    response header that tells htmx to close the modal once the round trip is complete. Works marvelously.
  • h

    handsome-gpu-11538

    07/27/2022, 5:23 PM
    that would work, but i was hoping to allow faster queueing of requests and not wait on the response...
  • h

    handsome-gpu-11538

    07/27/2022, 7:12 PM
    well, i found a solution. i'm not sure if it is a "bug" in htmx or rather just a "thing to be aware of"...
  • h

    handsome-gpu-11538

    07/27/2022, 7:13 PM
    hx-target does appear to be baked into the post, however hx-select gets pulled at swap time. so i removed my hx-select since my swapped html was already optimized down to the proper content. and now it works, even though the form gets tweaked mid-replacement.
  • b

    brainy-ice-92385

    07/27/2022, 7:14 PM
    Another option is to clone the modal before editing the hx- attributes and opening it (since you're already in JS land, not a huge lift), and delete each clone after swap. Well nevermind, you got a solution that works for you
  • h

    handsome-gpu-11538

    07/27/2022, 7:15 PM
    yeah cloning and orphaning would do it too. good idea! 🙂
  • h

    hundreds-camera-24900

    07/28/2022, 4:05 PM
    has anyone built a hx-twillio extension yet?
  • h

    hundreds-camera-24900

    07/28/2022, 4:05 PM
    feels like their lib + the client side template lib could automate most of real time chat setup through them
  • m

    most-activity-91725

    07/28/2022, 6:19 PM
    ~~Without knowing the specifics… could the web sockets/SSE capabilities cover this? https://htmx.org/docs/#websockets-and-sse ~~
  • m

    mysterious-toddler-20573

    07/28/2022, 8:55 PM
    https://twitter.com/htmx_org/status/1552754062948442130
  • h

    handsome-gpu-11538

    07/29/2022, 12:21 AM
    Well I created an issue in github related to my hx-select issue... I think they could make a nice easy fix that would cover the majority of cases that hit this issue. At minimum documentation of it would be helpful. 🙂 https://github.com/bigskysoftware/htmx/issues/990
  • c

    colossal-umbrella-30198

    07/29/2022, 4:55 AM
    How to define custom elements with htmx when we load partials ? 🥺
  • b

    big-rocket-55039

    07/29/2022, 6:46 AM
    thanks. i fixed it by adding CORS header on server side.
  • m

    many-rain-31921

    07/29/2022, 3:19 PM
    hi htmx folks! I am new here and currently using htmx and it works almost like a charm. I like it so much, because i don't need a big SPA, but just render all serverside (in rust) and then add some additional things with htmx and alpine.js. However I have a "flickering" UI issue and usually work on the backend side so please forgive me the "lower" level of question: I have a table at the end of a page and a pager at the bottom of the table. Clicking on a different page in the pager, loads the respective newly rendered table from the backend and uses hx-swap="outerHTML show:top". This leads to the issue, that (since the whole table is replaced), I have a scrolling behaviour happening after each page load which looks weird. Is there anything, htmx can do to that or do I have to use some "hacky css method" to keep a container around my swapped one with a somehow fixed size (the table entries are not always of the same height). Any hint or remark on how to generally tackle such an issue would be awesome!
  • m

    mysterious-toddler-20573

    07/29/2022, 3:24 PM
    what are you trying to do with that show:top?
  • m

    many-rain-31921

    07/29/2022, 3:26 PM
    the show:top is not really needed, it was my first try to achieve something. If you like, I can do a short screen recording to show the behaviour with show:top and without
  • m

    mysterious-toddler-20573

    07/29/2022, 3:36 PM
    By default, htmx shouldn't scroll anything
  • m

    mysterious-toddler-20573

    07/29/2022, 3:36 PM
    it should just swap the new content into the dom
  • m

    many-rain-31921

    07/29/2022, 3:39 PM
    jep, but due to the replacing of the table, on small screens i have this scroll / content jumping effect
  • m

    many-rain-31921

    07/29/2022, 3:40 PM
    without show:top i have to scroll down myself
1...764765766...1146Latest