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

    astonishing-teacher-48635

    10/31/2022, 5:29 PM
    is basically it
  • m

    mysterious-toddler-20573

    10/31/2022, 5:29 PM
    I vote you test if the first character is
    {
    and, if not, use the content as the text
  • m

    mysterious-toddler-20573

    10/31/2022, 5:29 PM
    so there's a simple version too
  • m

    mysterious-toddler-20573

    10/31/2022, 5:29 PM
    man, events are just the best
  • m

    mysterious-toddler-20573

    10/31/2022, 5:30 PM
    (when they work, and you don't have to debug them)
  • a

    astonishing-teacher-48635

    10/31/2022, 5:30 PM
    πŸ˜‚
  • r

    ripe-action-67367

    10/31/2022, 5:33 PM
    you can hook into htmx events to extract data from the response. By calling prevent default, you can stop further processing https://htmx.org/reference/#events . In this case, you are probably looking for
    htmx:beforeOnLoad
    or
    htmx:beforeSwap
    events, which happen after response is received but before any swapping. The former is raised on the element that issued the request, the latter is raised on the target.
  • q

    quiet-television-94579

    10/31/2022, 5:34 PM
    And thx a lot a third time πŸ™‚
  • r

    ripe-action-67367

    10/31/2022, 5:35 PM
    maybe beforeonload is more preferrable, cause before beforeswap is raised there is some processing of headers and such, you may or may not want that
  • r

    ripe-action-67367

    10/31/2022, 5:36 PM
    response data can be extracted from event.detail.xhr field
  • m

    mysterious-toddler-20573

    10/31/2022, 5:40 PM
    @ripe-action-67367 is absolutely crushing, I expect him to know htmx and be one with hypermedia better than me soon (if not already)
  • a

    astonishing-teacher-48635

    10/31/2022, 5:42 PM
    Copy code
    <button 
        hx-get="/test" 
        hx-ext="htmx-swal" 
        hx-swal-prompt='{"title": "This is a test prompt", "text": "Please enter your name", "icon": "info", "inputPlaceholder": "Please enter your name:"}'
    </button>
  • m

    mysterious-toddler-20573

    10/31/2022, 5:43 PM
    mmm
  • m

    mysterious-toddler-20573

    10/31/2022, 5:43 PM
    you need a way to add things
  • a

    astonishing-teacher-48635

    10/31/2022, 5:43 PM
    how so?
  • m

    mysterious-toddler-20573

    10/31/2022, 5:44 PM
    you want to add the name to the request, no?
  • a

    astonishing-teacher-48635

    10/31/2022, 5:44 PM
    this is where it gets fun
  • a

    astonishing-teacher-48635

    10/31/2022, 5:47 PM
    since issueRequest is paramless im guesing we will need another param like confirmed
  • a

    astonishing-teacher-48635

    10/31/2022, 5:48 PM
    issueAjaxRequest(verb, path, elt, event, etc, confirmed)
  • a

    astonishing-teacher-48635

    10/31/2022, 5:48 PM
    issueAjaxRequest(verb, path, elt, event, etc, confirmed, promptResponse)
  • a

    astonishing-teacher-48635

    10/31/2022, 5:48 PM
    😒
  • m

    mysterious-toddler-20573

    10/31/2022, 5:51 PM
    allow me time to think
  • b

    bitter-machine-55943

    10/31/2022, 6:00 PM
    Let’s get this on some HTMX merch
  • m

    mysterious-toddler-20573

    10/31/2022, 6:23 PM
    \> htmx merch \> in all my free time
  • m

    mysterious-toddler-20573

    10/31/2022, 6:30 PM
    Copy code
    javascript
      evt.detail.etc.values = {'name': nameFromSweetAlert2}
      evt.detail.issueRequest();
  • m

    mysterious-toddler-20573

    10/31/2022, 6:30 PM
    there is no problem in computer science that cannot be made worse by adding another layer of indirection
  • p

    prehistoric-wolf-75047

    10/31/2022, 9:03 PM
    is there any dom-morphing extension that preserves caret position and selection state when swapping
    <input>
    elements?
  • c

    cold-computer-43196

    10/31/2022, 9:47 PM
    Will the onbeforeunload event trigger htmx? Can try right now as I’m traveling but I was wondering. Building an erp and need a modal before they click away without saving invoice.
  • r

    ripe-action-67367

    10/31/2022, 9:54 PM
    Technically, I see not obstacles to trigger htmx request with this event, but, from my experience, you are unlikely to have time to actually send a request and display a modal, as it would be aborted by the browser. Implementing it with client-side scripting would be more reliable solution
  • c

    cold-computer-43196

    10/31/2022, 9:55 PM
    Okay. Will use the standard JS for this.
1...884885886...1146Latest