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

    mysterious-toddler-20573

    10/27/2022, 11:08 PM
    you can modify the behavior of htmx with respect to responses, if your server side framework wants to respond w/ a 204
  • m

    mysterious-toddler-20573

    10/27/2022, 11:09 PM
    set the
    evt.detail.shouldSwap
    to true for that status code
  • m

    mysterious-toddler-20573

    10/27/2022, 11:09 PM
    https://gist.github.com/1cg/946ad4a34096ced10dc32f5094dc8737
  • b

    busy-action-85810

    10/27/2022, 11:12 PM
    1cg: Thanks. I wasn't familiar with events until now. I need to play with this more but I see how to alter behavior.
  • m

    mysterious-toddler-20573

    10/27/2022, 11:12 PM
    👍 I agree w/ Deniz that the easy way out is to return a 200 w/ empty content, but if your server side framework (or ideology) requires a 204, you can make htmx do what you want
  • b

    busy-action-85810

    10/27/2022, 11:14 PM
    Yeah, I guess I'm missing community context on the 204 debate but I'm not sure I follow why HTMX doesn't recognize 204 as no content and simply swaps with nothing. I can change the server code too but wanted to understand how to do this if that wasn't possible too. 😉
  • m

    mysterious-toddler-20573

    10/27/2022, 11:15 PM
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204
  • m

    mysterious-toddler-20573

    10/27/2022, 11:15 PM
    > The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate away from its current page.
  • m

    mysterious-toddler-20573

    10/27/2022, 11:16 PM
    unfortunately the REST JSON API world also picked it up as "There is literally nothing here" for DELETES
  • m

    mysterious-toddler-20573

    10/27/2022, 11:16 PM
    and here we are
  • b

    busy-action-85810

    10/27/2022, 11:16 PM
    Well, drat. I missed that part. I wasn't reading the specification properly. Thanks!
  • g

    gorgeous-airport-54386

    10/27/2022, 11:16 PM
    the correct code for a successful delete is 200, regardless of how long the response is
  • m

    mysterious-toddler-20573

    10/27/2022, 11:17 PM
    lol
  • m

    mysterious-toddler-20573

    10/27/2022, 11:17 PM
    you either die someone who hates pedantic HTTP response code arguments or you don't
  • m

    mysterious-toddler-20573

    10/27/2022, 11:17 PM
    but I tend to agree w/ young deniz
  • m

    mysterious-toddler-20573

    10/27/2022, 11:18 PM
    speaking of which, deniz do you have any brain power left over to think about the head tag issue?
  • g

    gorgeous-airport-54386

    10/27/2022, 11:18 PM
    seems like ids can be used
  • m

    mysterious-toddler-20573

    10/27/2022, 11:18 PM
    ids on head elements?
  • g

    gorgeous-airport-54386

    10/27/2022, 11:18 PM
    yeah
  • m

    mysterious-toddler-20573

    10/27/2022, 11:18 PM
    🤔
  • g

    gorgeous-airport-54386

    10/27/2022, 11:19 PM
    just to match things up
  • m

    mysterious-toddler-20573

    10/27/2022, 11:19 PM
    Ah, I'm not worried about that, we can just use the outerHTML (it's so small that it doesn't matter)
  • g

    gorgeous-airport-54386

    10/27/2022, 11:19 PM
    you can have a
    <style id="page-specific-styles">
    for instance
  • m

    mysterious-toddler-20573

    10/27/2022, 11:19 PM
    mmmm
  • m

    mysterious-toddler-20573

    10/27/2022, 11:19 PM
    that would work given the current logic
  • g

    gorgeous-airport-54386

    10/27/2022, 11:19 PM
    and that would replace the old style tag even on append
  • m

    mysterious-toddler-20573

    10/27/2022, 11:20 PM
    @bitter-machine-55943 mentioned he was surprised when I "synced" styles
  • m

    mysterious-toddler-20573

    10/27/2022, 11:20 PM
    but @echoing-action-55459 's idea of defaulting to "sync" for boosts and "append" for non-boosts might obviate that issue
  • g

    gorgeous-airport-54386

    10/27/2022, 11:21 PM
    if you swap the same thing again does it clean up or does it accumulate
  • m

    mysterious-toddler-20573

    10/27/2022, 11:21 PM
    "it depends"
1...877878879...1146Latest