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

    orange-umbrella-16693

    02/11/2023, 11:09 AM
    why does
    hx-swap="beforeend"
    duplicate the response in this example? https://jsfiddle.net/rtncv62o/
  • r

    ripe-action-67367

    02/11/2023, 11:30 AM
    Interesting
  • r

    ripe-action-67367

    02/11/2023, 11:30 AM
    Looks like a bug, specific to demo script
  • o

    orange-umbrella-16693

    02/11/2023, 11:34 AM
    oh well
  • o

    orange-umbrella-16693

    02/11/2023, 11:47 AM
    Also, swap/settle should work for hx-swap-oob if it allows any valid hx-swap value, right? So I could theoretically have the response have
    Copy code
    html
    <div>
    ...
    </div>
    <img hx-swap-oob="delete swap:1s, #myimage">
    if I want to delete the
    #myimage
    element 1s after the request is swapped in?
  • c

    crooked-winter-42525

    02/11/2023, 4:25 PM
    Would be interested in your solution if you could share the hyperscript code. Need to learn a bit more hyperscript.
    i
    • 2
    • 20
  • c

    crooked-winter-42525

    02/11/2023, 4:27 PM
    Did this work? I’m currently planning to do some testing with swap modifiers with OOB swaps.
  • o

    orange-umbrella-16693

    02/11/2023, 4:28 PM
    Not in the jsfiddle demo, no. Though with that earlier example failing I'd blame it on the test environment. I didn't check in a normal site yet.
  • c

    crooked-winter-42525

    02/11/2023, 4:29 PM
    Sounds good. Thanks for the quick reply.
  • o

    orange-umbrella-16693

    02/11/2023, 5:49 PM
    Unfortunately doesn't seem like it.
  • f

    future-leather-60338

    02/11/2023, 5:50 PM
    in HTMX, how do I "Configure any AJAX calls that POST data to my server to pass the authenticityToken from the as an X-CSRF-TOKEN HTTP header.
  • f

    future-leather-60338

    02/11/2023, 5:53 PM
    ... my form is <form action="/examples/edit" hx-put="/examples/1" hx-target="#htmx-container" method="post"> ... Name Save
  • o

    orange-umbrella-16693

    02/11/2023, 5:59 PM
    this seems to work:
    Copy code
    html
    <div hx-trigger="click" hx-get="/" hx-swap="none"
      hx-headers="js:{ 'X-CSRF-TOKEN': document.querySelector('meta[name=\'csrf-token\']').content }">
      Click me
    </div>
    although not pretty
  • c

    crooked-winter-42525

    02/11/2023, 6:18 PM
    Could it be that the OOB doesn’t like the target being added with the comma? Just setting the target on the element and then doing hx-swap=“outerHTML swap:1s”
  • o

    orange-umbrella-16693

    02/11/2023, 6:25 PM
    That also produces an error
    1s is not a valid selector
  • c

    crooked-winter-42525

    02/11/2023, 6:26 PM
    Which version of HTMX?
  • c

    crooked-winter-42525

    02/11/2023, 6:27 PM
    This would be a good add of if it doesn’t work as getting css animations to work with OOB swaps would be very useful.
  • o

    orange-umbrella-16693

    02/11/2023, 6:29 PM
    1.8.5
  • c

    crooked-winter-42525

    02/11/2023, 6:32 PM
    Going to test this more this afternoon rather than asking you to do it ha.
  • o

    orange-umbrella-16693

    02/11/2023, 6:33 PM
    lmk how it goes anyways
  • o

    orange-umbrella-16693

    02/11/2023, 6:51 PM
    alternatively one could write a middleware for some htmx event idk
  • b

    brief-flower-84254

    02/11/2023, 8:02 PM
    Cool. Took a little more time than I wanted, but I've got a simple expressjs project using typescript + prisma + ejs + htmx + tailwind.
  • c

    crooked-winter-42525

    02/11/2023, 8:44 PM
    Confirmed. The docs do say any valid swap value but it seems to only be the main values and not the modifiers.
  • o

    orange-umbrella-16693

    02/11/2023, 8:44 PM
    😦
  • c

    crooked-winter-42525

    02/11/2023, 8:45 PM
    Yeah, bummer for now.
  • f

    flat-room-63432

    02/11/2023, 11:40 PM
    Not sure where to post it, but was a) looking at backend options outside my normal ecosystem, and b) reading the template fragments essay linked on the html_org twitter this week. TLDR I found another template fragment implementation to add to the list in that essay. https://laravel.com/docs/9.x/blade#rendering-blade-fragments
  • f

    flat-room-63432

    02/11/2023, 11:46 PM
    I see it’s already been linked in #939530480636809227, I don’t know why I didn’t think to look at that first, other than that I just don’t go to that channel because I don’t normally work in php. Anyway, the essay linked here to submit new implementation for inclusion in the list, so I did.
  • b

    brief-flower-84254

    02/12/2023, 2:41 AM
    I'm getting a strange error when using the browser back button. Haven't done anything super complicated yet, just navigating between a couple pages targeting a 'main' div.
    Copy code
    libs.js:1908 Uncaught TypeError: Cannot read properties of null (reading 'dispatchEvent')
        at triggerEvent (libs.js:1908:35)
        at restoreHistory (libs.js:2073:17)
        at window.onpopstate (libs.js:3382:21)
    I set a breakpoint in restoreHistory and it looks like getDocument().body is null. Any ideas?
  • m

    mysterious-toddler-20573

    02/12/2023, 3:03 AM
    how could document be null?
  • b

    brief-flower-84254

    02/12/2023, 3:03 AM
    document isn't null, but body is
1...101710181019...1146Latest