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

    abundant-spring-38265

    10/14/2022, 10:31 AM
    Guys, ia there anything special required to get hx-get working from within a datatable (DataTables.net)?
  • a

    abundant-spring-38265

    10/14/2022, 10:31 AM
    P.S, paging is enabled
  • a

    abundant-spring-38265

    10/14/2022, 10:32 AM
    Pagination
  • m

    mysterious-toddler-20573

    10/14/2022, 1:28 PM
    Yeah htmx/intercooler started out focused on partial html replacement, in contrast with turbo links, which was whole-page focused. I threw boosting in as an afterthought. Interesting that turbo links/Hotwire was the opposite move.
  • w

    worried-portugal-65416

    10/14/2022, 3:08 PM
    Hi, I'd like to modify the value of an empty input element before its data is sent via a POST request. Any ideas on how to go about it? I have tried changing it via hyperscript at the htmx:beforeSend and htmx:beforeRequest stages and the browser inspector shows the changed value but the post request info still sees it as empty
  • l

    limited-dress-93789

    10/14/2022, 5:44 PM
    When using an
    hx-post="…"
    on a form, what's the easiest way to clear the form on successful execution of the request?
  • m

    mysterious-toddler-20573

    10/14/2022, 5:46 PM
    What are you targeting?
  • m

    mysterious-toddler-20573

    10/14/2022, 5:46 PM
    this should work, can we see your code?
  • l

    limited-dress-93789

    10/14/2022, 5:47 PM
    The
    beforeend
    of a
    <div>
    . It's kind of a guestbook to which the form submission adds entries.
  • m

    mysterious-toddler-20573

    10/14/2022, 5:47 PM
    OK, I would trigger a custom event, "addedEntry" or similar, listen for that and call https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset
  • m

    mysterious-toddler-20573

    10/14/2022, 5:48 PM
    alternatively you could use an out of band response to do the append and just return the form html, w/ the form as the target
  • m

    mysterious-toddler-20573

    10/14/2022, 5:48 PM
    a few different approaches, depending on what is easiest and clearest based on your back-end
  • l

    limited-dress-93789

    10/14/2022, 5:49 PM
    I had hoped that some attribute on the form and maybe some hyperscript would do the trick.
  • m

    mysterious-toddler-20573

    10/14/2022, 5:54 PM
    you can definitely do it in hyperscript
  • m

    mysterious-toddler-20573

    10/14/2022, 5:54 PM
    the problem is that it sounds like it's conditional
  • m

    mysterious-toddler-20573

    10/14/2022, 5:54 PM
    are you showing error messages, or is this on every submission regardless?
  • m

    mysterious-toddler-20573

    10/14/2022, 5:55 PM
    if it isn't conditional we can toss some hyperscript on it and be done
  • l

    limited-dress-93789

    10/14/2022, 5:55 PM
    I tried
    _="on htmx:entryAdded this.reset()"
    on the
    <form>
    element.
  • l

    limited-dress-93789

    10/14/2022, 5:55 PM
    It's a demo so it doesn't need to be perfct.
  • m

    mysterious-toddler-20573

    10/14/2022, 5:56 PM
    You'd do:
    Copy code
    applescript
      on entryAdded reset() me
  • m

    mysterious-toddler-20573

    10/14/2022, 5:56 PM
    one sec, lemme get a demo going
  • m

    mysterious-toddler-20573

    10/14/2022, 5:58 PM
    https://codepen.io/1cg/pen/GRdeqaX?editors=1000
  • m

    mysterious-toddler-20573

    10/14/2022, 5:59 PM
    you'd trigger
    entryAdded
    w/ the
    HX-Trigger
    response header
  • m

    mysterious-toddler-20573

    10/14/2022, 5:59 PM
    pretty clean
  • l

    limited-dress-93789

    10/14/2022, 6:18 PM
    Hm, I see the request executed, the response header but the reset doesn't seem to get triggered.
  • l

    limited-dress-93789

    10/14/2022, 6:18 PM
    That said, it doesn't seem to work in the link you sent. Maybe a browser issue?
  • l

    limited-dress-93789

    10/14/2022, 6:19 PM
    Nope. Switching to Safari doesn't change the outcome.
  • m

    mysterious-toddler-20573

    10/14/2022, 6:23 PM
    hmmm
  • m

    mysterious-toddler-20573

    10/14/2022, 6:23 PM
    it works for me in chrome and firefox, but not safari
  • m

    mysterious-toddler-20573

    10/14/2022, 6:23 PM
    truly, the new IE
1...855856857...1146Latest