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

    bitter-machine-55943

    10/23/2022, 10:06 PM
    https://dl.acm.org/doi/abs/10.1145/376284.375737 this?
  • b

    boundless-vase-80440

    10/23/2022, 10:19 PM
    no, it was a blog post by some european guy...
  • e

    eager-agency-92101

    10/23/2022, 11:48 PM
    Imagine we have a scenario A uesr is on version 1.1
    Copy code
    html
      # version 1.1
      <div>
        Click and see a RED button
        <button hx-get="/click" hx-trigger="click" hx-swap="outerHTML">
          A button
        </button>
      </div>
    
      # url /click returns
      <button hx-get="/click" hx-swap="outerHTML" style="color: red">
        I am red
      </button>
    Later, a new version 1.2 has been release to public
    Copy code
    html
      # version 1.2
      <div>
        Click and see a Blue button
        <button hx-get="/click" hx-trigger="click" hx-swap="outerHTML">
          A button
        </button>
      </div>
    
      # url /click returns
      <button hx-get="/click" hx-swap="outerHTML" style="color: blue">
        I am blue
      </button>
    The user who is on 1.1 cicked the button and the blue button(version 1.2) is sent and resulted in the wrong expectation. How would we overcome this problem?
  • b

    brainy-ice-92385

    10/23/2022, 11:50 PM
    You could have a version in the cookie, and if the version differs btwn request and response, force a full refresh on the client
  • e

    eager-agency-92101

    10/23/2022, 11:53 PM
    That is an option. However, while the the particular browser tab is stayed on v1.1 and he opens a new tab, the cookie get updated. Then the user goes back to the original 1.1 tab, I believe the version in the cookie and the response will just match?
  • e

    eager-agency-92101

    10/23/2022, 11:54 PM
    I believe store the current version in a JS var will be better
  • b

    brainy-ice-92385

    10/23/2022, 11:55 PM
    Ya both, another place for a mismatch
  • e

    eager-agency-92101

    10/23/2022, 11:56 PM
    I am still thinking about the approach of force reloading. If that happens in a ui modal or form, it will pretty annoying to user.
  • b

    brainy-ice-92385

    10/23/2022, 11:59 PM
    Ya I mean this is a problem w any server/client relationship, not anything specific to htmx or hotw
  • e

    eager-agency-92101

    10/24/2022, 12:01 AM
    yes, I am just wondering if htmx offers magic to this as well.
  • v

    victorious-match-64854

    10/24/2022, 12:14 AM
    in the Stacks it would be good to add ASTRO
  • v

    victorious-match-64854

    10/24/2022, 12:14 AM
    astro.build
  • m

    mysterious-toddler-20573

    10/24/2022, 2:01 AM
    An option is to keep a version cookie and check that at the start of every request, and, if the client is out of date, use a response header to trigger an event telling the client to reload (or just hard reload, according to tastes)
  • b

    bitter-machine-55943

    10/24/2022, 2:33 AM
    One thing on
    head-support
    , I noticed there’s a
    <style>
    tag that gets added for
    .htmx-indicator
    which seems to be dynamically added. If I mark all of the
    <head>
    contents with
    hx-preserve=“true”
    , that
    <style>
    tag gets removed the first time a head swap occurs. That’s as expected, but may not be what someone wants. Makes me wonder if there should be a way to default everything to
    hx-preserve=“true”
    prior to any head swaps, and allow setting
    hx-preserve=“false”
    (or similar) so that the page-specific stuff that got swapped into head doesn’t remain after subsequent head swaps.
  • m

    mysterious-toddler-20573

    10/24/2022, 2:38 AM
    mmmm
  • m

    mysterious-toddler-20573

    10/24/2022, 2:38 AM
    good point
  • m

    mysterious-toddler-20573

    10/24/2022, 2:38 AM
    I'll think more
  • s

    salmon-xylophone-28580

    10/24/2022, 6:30 AM
    I got a message from someone new to htmx and new to web development. AFAIK plattforms like jsfiddle don't work well for htmx, because you need to create snippets-responses, which is (AFAIK) not supported by jsfiddle-like services. But maybe I just don't know this cool plattform yet where you can edit htmx and have an extra tab to create responses, so that you can create self-containing examples which you can use for non-abstract discussions about code.
  • r

    ripe-action-67367

    10/24/2022, 6:48 AM
    https://htmx.org/docs/#creating-demos
  • r

    ripe-action-67367

    10/24/2022, 6:50 AM
    This will work on js fiddle, codepen, anywhere
  • r

    ripe-action-67367

    10/24/2022, 6:52 AM
    It's not perfect, htmx extensions may not work, it's a known problem, but for most cases this script is perfect
  • s

    salmon-xylophone-28580

    10/24/2022, 7:17 AM
    thank you. And I learned about the
    output
    tag. Never seen it before. Thank you.
  • b

    boundless-leather-51644

    10/24/2022, 8:19 AM
    Hi
  • b

    boundless-leather-51644

    10/24/2022, 8:19 AM
    What is the purpose of HX-Request as the doc is not clear enough for me ?
  • t

    tall-dinner-62086

    10/24/2022, 8:20 AM
    It tells the server that the request came from htmx
  • b

    boundless-leather-51644

    10/24/2022, 8:49 AM
    ok. So we can populate a response which is different depending if htmx is in the loop or not
  • i

    icy-analyst-57034

    10/24/2022, 9:13 AM
    Hey all, I'm wondering if it's possible to use hx-confirm in conjunction with hx-trigger delay like so:
    Copy code
    html
    <form 
        hx-post="/some-url"
        hx-confirm="Are you sure you want to do the action?"
        hx-trigger="confirm delay:500ms"
    >
      <button>Do Action</button>
    </form>
    I'm trying to get the delay to be after the confirm message has been OK'd, but I'm not having any luck with it. Any help would be appreciated 🙂
  • b

    boundless-leather-51644

    10/24/2022, 11:00 AM
    Why is HTMX expecting to get HTML and not JSON ?
  • b

    boundless-leather-51644

    10/24/2022, 11:00 AM
    Is it planned that HTMX will support JSON as response output ?
  • m

    miniature-lizard-24702

    10/24/2022, 11:05 AM
    because html is the entire point?
1...869870871...1146Latest