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

    gorgeous-ghost-95789

    12/24/2020, 3:34 AM
    Ok. So the internal htmx code would use a "custom"
    onload
    handler that called other extensions, and handled response headers.
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:35 AM
    By default, I think it just caches based on the URL. But you can use the HTTP
    Vary
    Header to change that. As an example, I usually use
    Vary:Authentication
  • m

    mysterious-toddler-20573

    12/24/2020, 3:36 AM
    > As discussed above, caching servers will by default match future requests only to requests with exactly the same headers and header values.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:36 AM
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
  • m

    mysterious-toddler-20573

    12/24/2020, 3:36 AM
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#Normalization
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:36 AM
    Hmmmm.. So ALL the headers would need to match?
  • m

    mysterious-toddler-20573

    12/24/2020, 3:36 AM
    it's dumb how little I know about HTTP after nearly 25 years of this stuff
  • m

    mysterious-toddler-20573

    12/24/2020, 3:37 AM
    Looks like it, but that's what we will get, so it's all good
  • m

    mysterious-toddler-20573

    12/24/2020, 3:37 AM
    This is a good change
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:37 AM
    Yes, this is a good change.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:37 AM
    opens up some interesting possibilities in hyperscript too
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:37 AM
    Since htmx includes so much information in the headers, it may cause more cache misses than we intend. I think we'll need to experiment.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:38 AM
    good point
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:38 AM
    Yes. All of these features would be fantastic for hyperscript to access.
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:39 AM
    Along these lines #255 - "Publish swap() function to external scripts" seems like a logical next step.
  • s

    salmon-xylophone-28580

    12/24/2020, 6:43 AM
    I have not though about this yet. But this could be a drawback in the long run. Up to now my small applications does not rely on those headers, maybe htmx should not send them by default, only if enabled explicitly. But only if these headers will cause http caches to not cache these requests.
  • m

    mysterious-toddler-20573

    12/24/2020, 1:04 PM
    OK, I have made a few changes: * I refactored and cleaned up the signatures for ajax handling * There is now an
    htmx.ajax
    API method (still need to document it) * I removed some headers that would vary between requests. They were speculative and not a crux feature, and people can add then back via hyperscript or whatever if they want them
  • m

    mysterious-toddler-20573

    12/24/2020, 1:07 PM
    @User for your use case, I think you want something like this:
    Copy code
    js
      htmx.ajax("GET", whateverThePathIs, 
                {source:theElement, 
                 handler:function(){/* do nothing, allow response to cache */ })
  • m

    mysterious-toddler-20573

    12/24/2020, 1:09 PM
    For someone who wants to issue a request manually and target element #foo, they can say:
    Copy code
    js
      htmx.ajax("GET", "/whatever", "#foo")
  • m

    mysterious-toddler-20573

    12/24/2020, 1:37 PM
    also just implemented this: https://github.com/bigskysoftware/htmx/issues/284
  • g

    gorgeous-ghost-95789

    12/24/2020, 9:57 PM
    This will be awesome. Where should I look for it, dev branch?
  • g

    gorgeous-ghost-95789

    12/24/2020, 9:58 PM
    I like the idea of limiting the headers that are sent by default, then possibly adding them back in (via extensions?) for those who need them.
  • m

    mysterious-toddler-20573

    12/24/2020, 11:33 PM
    dev branch
  • u

    user

    12/25/2020, 7:45 AM
    Here after the recent launch of hot-wire. I fundamentally see a lot of value in projects like HTMX and Hot-wire both, but HTMX feels more complete for my needs I am trying to build a demo app which behaves a bit like product hunt (in terms of interactivity) with HTMX and see how far I can get. Will post my progress and issues here 🙂
  • u

    user

    12/25/2020, 8:23 AM
    What is the best way to disable a button when a request is in progress?
  • u

    user

    12/25/2020, 9:08 AM
    Also related to this. Is it possible to only scope the
    htmx-request
    class to the current element parent. Otherwise if I have multiple loading elements on a page, they all start spinning
  • g

    gorgeous-ghost-95789

    12/25/2020, 6:13 PM
    Hey @User -- welcome to the chat! htmx generates tons of events during an xhr request. You can listen to these from plain Javascript (or Hyperscript) to toggle properties on your buttons.
  • g

    gorgeous-ghost-95789

    12/25/2020, 6:15 PM
    For submit buttons, I also like having two separate components on the page -- a real button that is visible until clicked, and a "disabled" one with different text and a spinner that starts off invisible. When the user clicks the real button, use Javascript to hide it and show the disabled one.
  • g

    gorgeous-ghost-95789

    12/25/2020, 6:16 PM
    Try listening for htmx:beforeRequest [https://htmx.org/events/#htmx:beforeRequest]
  • s

    salmon-xylophone-28580

    12/25/2020, 8:23 PM
    @User thank you for your link to beforeRequest. Since it is a very common use-case it would great if it would be possible to disable a button and show a spinner without using JS.
1...110111112...1146Latest