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

    ancient-father-3063

    07/02/2022, 11:44 AM
    like if I have form A trigger on change, and that trigger targets form B. But form B also has an hx-trigger=Change, should that trigger?
  • r

    ripe-action-67367

    07/02/2022, 12:50 PM
    you can send empty form in the response as oob swap. But honestly, I would use JS (or hyperscript).
    Copy code
    on htmx:afterRequest[detail.successful] reset() me
  • r

    ripe-action-67367

    07/02/2022, 12:53 PM
    Probably shouldn't > The change event is fired for , , and elements when an alteration to the element's value is committed by the user. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value. > https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
  • a

    ancient-father-3063

    07/02/2022, 1:24 PM
    That's what I thought ok
  • m

    mysterious-toddler-20573

    07/02/2022, 3:20 PM
    https://frontendmastery.com/posts/the-new-wave-of-react-state-management/
  • m

    mysterious-toddler-20573

    07/02/2022, 3:29 PM
    https://twitter.com/GrugBrainedDev/status/1543255276438036483
  • r

    red-farmer-97020

    07/02/2022, 3:32 PM
    I'd love to hear grug describe the best way to do form validation with hypermedia
  • r

    red-farmer-97020

    07/02/2022, 3:33 PM
    (that's a common response I get when talking about HTMX - form validation requires a trip to the server)
  • m

    most-activity-91725

    07/02/2022, 3:53 PM
    Validation should probably happen (or is already happening) on the server anyway… In my experience, having access to the populated data model / submission in the template/view and outputting submitted values and validation issues (as you would with a traditional MPA) works pretty well!
  • p

    powerful-train-54786

    07/02/2022, 3:56 PM
    Client form validation has given me nothing but hell over the years. Seen it done, and redone, and redone for the same application
  • p

    powerful-train-54786

    07/02/2022, 3:57 PM
    Most of the issue is the insistence on the client-code handling a lot of scenarios, when it really needs to be "API first". That catch phrase that everyone says but never actually likes doing
  • r

    refined-waiter-90422

    07/02/2022, 4:11 PM
    Validation has to happen on the server anyway. HTMX can make it nice enough that it feels client side.
  • r

    refined-waiter-90422

    07/02/2022, 4:19 PM
    although we always need docs of good patterns on htmx.org, for sure.
  • r

    refined-waiter-90422

    07/02/2022, 4:23 PM
    we're all so early to the party I think a lot of the best, shortest, language agnostic patterns using the building blocks htmx / hyperscript gives us are still yet to be documented.
  • m

    mysterious-toddler-20573

    07/02/2022, 4:40 PM
    htmx is a html 5 validation respector: https://developer.mozilla.org/en-US/docs/Web/API/Constraint_validation
  • m

    mysterious-toddler-20573

    07/02/2022, 5:12 PM
    it's a shitposting day I guess
  • m

    mysterious-toddler-20573

    07/02/2022, 5:12 PM
    https://twitter.com/htmx_org/status/1543280586479091714
  • h

    hundreds-kitchen-60317

    07/02/2022, 6:14 PM
    I just spent two days(12 hours daily), writing damn comment display and pagination(json from backend) in JQuery. I'm really ready for something like HTMX.
  • m

    mysterious-toddler-20573

    07/02/2022, 7:43 PM
    Copy code
    html
      <a hx-get="/post/${post.id}/comments?page=${page + 1}" ...>
         Load More
      </a>
  • h

    hundreds-kitchen-60317

    07/02/2022, 7:44 PM
    That's more like it.
  • l

    late-king-98305

    07/03/2022, 3:01 AM
    The easiest htmx way to do this would be to always return the list and an empty form, assuming you're persisting the list on the server. When you first pull, the page contains "the list" (nothing, because it's empty) and a form. When you submit the form, you persist item one, and return "the list" (now with 1 item) and the same empty form. Repeat to your heart's content. You can come back to your list, and it's still there; you can add more later. (If you're not persisting the list on the server, then the above doesn't apply; but, if you're persisting it in the browser, you wouldn't need to "submit" it anywhere.)
  • h

    hundreds-kitchen-60317

    07/03/2022, 1:06 PM
    So I've heard it's best practice to use with another library like Alpine?
  • m

    mysterious-toddler-20573

    07/03/2022, 2:23 PM
    vanillajs, alpine or hyperscript seem to be the most popular for front end scripting needs
  • a

    ancient-father-3063

    07/03/2022, 3:17 PM
    Copy code
    html
    hx-include="#previous select"
  • a

    ancient-father-3063

    07/03/2022, 3:18 PM
    @mysterious-toddler-20573 is this supposed to work? Am I doing it wrong?
  • m

    mysterious-toddler-20573

    07/03/2022, 3:50 PM
    previous select
  • m

    mysterious-toddler-20573

    07/03/2022, 3:50 PM
    # is the start of an id reference
  • h

    hundreds-kitchen-60317

    07/03/2022, 3:52 PM
    Are there shortcommings of htmx where it's needed?
  • m

    mysterious-toddler-20573

    07/03/2022, 3:57 PM
    if you want pure client side interactions, such as toggling a class on a div or whatever, and a server round trip isn't ideal
  • a

    ancient-father-3063

    07/03/2022, 10:51 PM
    how do I add a custom parameter without taking away the default parameter?
1...733734735...1146Latest