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

    calm-tiger-90815

    07/31/2022, 8:03 PM
    Hello humans! I really like the way HTMX works. I searched for alternatives that do things similar to HTMX. But I found nothing. Are there some alternatives?
  • m

    mysterious-toddler-20573

    07/31/2022, 8:04 PM
    Unpoly and Hotwire (by 37signals) are two. There is also twinspark.
  • m

    mysterious-toddler-20573

    07/31/2022, 8:05 PM
    What back end are you using? There are also things like livewire and unicorn-django
  • b

    brainy-ice-92385

    07/31/2022, 8:21 PM
    We were talking in #796428329531605032 about form validation w htmx and I thought I'd repeat my idea here. Has anyone tried something similar? Any obvious flaws? Upon form submission, if the backend detects invalid fields, it sends back ONLY oob swaps which target (previously empty) text fields under each invalid input. Those oob swaps fill those text fields with the validity message, e.g. "passwords must be at least 8 characters". This is opposed to the basic htmx implementation where the whole
    <form />
    gets swapped. This would add complexity but the benefit is that the user's cursor could be preserved. E.g. if a user is typing their email, then hits Enter to submit, their cursor would remain in the same place when the validation errors appear.
  • c

    calm-tiger-90815

    07/31/2022, 8:24 PM
    @mysterious-toddler-20573 Thanks for the answers! I will look into them! I use PHP as a backend.
  • b

    brainy-ice-92385

    07/31/2022, 8:24 PM
    See the #939530480636809227 channel if you haven't yet!
  • m

    mysterious-toddler-20573

    07/31/2022, 8:53 PM
    if the input has an ID, we should attempt to preserve cursor and focus
  • m

    mysterious-toddler-20573

    07/31/2022, 8:54 PM
    in htmx 2.0 I'd like to work on a "merge" swap strategy, based on https://github.com/choojs/nanomorph that makes this easier
  • b

    brainy-ice-92385

    07/31/2022, 8:55 PM
    I assume you mean that's a future idea, not a current expectation? I agree that would be rad
  • m

    mysterious-toddler-20573

    07/31/2022, 8:59 PM
    i swear I added this
  • m

    mysterious-toddler-20573

    07/31/2022, 8:59 PM
    looking
  • m

    mysterious-toddler-20573

    07/31/2022, 9:00 PM
    https://github.com/bigskysoftware/htmx/blob/c77eeb4c9b39ca807d46ab0bf5c40ac0db6f3b92/src/htmx.js#L3021
  • m

    mysterious-toddler-20573

    07/31/2022, 9:00 PM
    we try to preserve the active element and its selection
  • m

    mysterious-toddler-20573

    07/31/2022, 9:00 PM
    😑
  • b

    brainy-ice-92385

    07/31/2022, 10:14 PM
    Oh wow, I didn't realize this. I honestly hadn't tried it, I thought the swap was totally naive
  • h

    hundreds-camera-24900

    07/31/2022, 11:21 PM
    I couldn't get nanomorph working that well for me btw
  • h

    hundreds-camera-24900

    07/31/2022, 11:21 PM
    I'll give it another try next chance I have
  • l

    little-journalist-53964

    08/01/2022, 10:47 AM
    What is
    <timing declaration>
    as per https://htmx.org/attributes/hx-trigger/? Would be nice to have the grammar specified somewhere
  • t

    tall-dinner-62086

    08/01/2022, 10:54 AM
    There are examples down in the Polling section
  • l

    late-king-98305

    08/01/2022, 1:22 PM
    BTW - lest I do the Stack Overflow "I figured it out" thing... my "duck" comment was borne of an app that I'm working to htmxify (TM). Server-side, I need to know the target of an htmx request, so I know which layout to render with the result. (Unauthenticated requests bounce through the log on page, and once the user logs on, I refresh the menus; otherwise, I just replace the "content" portion of the page, which excludes the menus.) The solution to this is to handle `htmx:configRequest`; the target is a property of the event's detail. I can send that via a custom header, then use that to determine how to render the result. https://htmx.org/events/#htmx:configRequest
  • m

    mysterious-toddler-20573

    08/01/2022, 1:39 PM

    https://www.youtube.com/watch?v=LRrrxQXWdhIâ–¾

  • t

    tall-dinner-62086

    08/01/2022, 2:23 PM
    How do I get htmx to honor a
    Content-Disposition: attachment
    header? I'm trying to trigger a file download from an hx-get
  • t

    tall-dinner-62086

    08/01/2022, 2:23 PM
    It is currently just grabbing the csv as text and replacing the implicit target
  • r

    ripe-action-67367

    08/01/2022, 2:34 PM
    I don't think you can download files with ajax. There is Blob API afaik, but that would require some custom js.
  • t

    tall-dinner-62086

    08/01/2022, 2:35 PM
    That would certainly explain a lot
  • t

    tall-dinner-62086

    08/01/2022, 2:36 PM
    I thought I'd be clever and use the
    Accept
    header to allow users to download reports in their preferred format, but it's looking like more trouble than it's worth
  • m

    mysterious-toddler-20573

    08/01/2022, 2:38 PM
    Easiest thing is to make it a normal link, if you are boosting links then you can use
    hx-boost='false'
    on the download link
  • t

    tall-dinner-62086

    08/01/2022, 2:39 PM
    What I wanted was to just
    <button hx-get="" hx-headers='{"Accept": "text/csv"}'>
    and then on the backend I could just look at the
    Accept
    header to set the return types
  • t

    tall-dinner-62086

    08/01/2022, 2:39 PM
    But I guess I'll have to make do with something else
  • r

    ripe-action-67367

    08/01/2022, 2:40 PM
    May I suggest query parameters? I have a feeling that headers may cause some trouble, especially when dealing with caching and link sharing
1...766767768...1146Latest