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

    gorgeous-ghost-95789

    12/24/2020, 2:28 AM
    Plus, it’s written very conservatively right now, so the preload is not applied unless you explicitly put a preload attribute on the element. So you’ve really chosen to do this.
  • m

    mysterious-toddler-20573

    12/24/2020, 2:28 AM
    Ah
  • m

    mysterious-toddler-20573

    12/24/2020, 2:28 AM
    YOU ASKED FOR THIS
  • g

    gorgeous-ghost-95789

    12/24/2020, 2:29 AM
    This.
  • m

    mysterious-toddler-20573

    12/24/2020, 2:30 AM
    OK, so the problem is that the request needs to include the pre-request logic from htmx core
  • g

    gorgeous-ghost-95789

    12/24/2020, 2:30 AM
    Yes please.
  • g

    gorgeous-ghost-95789

    12/24/2020, 2:30 AM
    Access to the built-in xhr function would address it.
  • m

    mysterious-toddler-20573

    12/24/2020, 2:31 AM
    but you need a no-op
    xhr.onload
  • g

    gorgeous-ghost-95789

    12/24/2020, 2:31 AM
    Yes. I’d assume the function we publish would accept a callback (or promise, or whatever). From this extension, we’d just pass an empty function.
  • m

    mysterious-toddler-20573

    12/24/2020, 2:32 AM
    OK
  • m

    mysterious-toddler-20573

    12/24/2020, 2:32 AM
    i need to look at that method and think
  • g

    gorgeous-ghost-95789

    12/24/2020, 2:32 AM
    Yup. I think it will be a little painful, but a good step forward.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:24 AM
    proposed sig:
    Copy code
    js
      htmx.ajax(verb, path, [elt default: body], [onload default: normal swap algorithm])
  • m

    mysterious-toddler-20573

    12/24/2020, 3:25 AM
    Copy code
    js
      htmx.ajax('GET', "/foo")
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:25 AM
    Thank you for your attention on this 🙂 What function would
    elt
    support?
  • m

    mysterious-toddler-20573

    12/24/2020, 3:25 AM
    or, for this use case
  • m

    mysterious-toddler-20573

    12/24/2020, 3:26 AM
    Copy code
    js
      htmx.ajax('GET', "/foo", theEltWeArePreloadingFor, function(){ /* do nothing, cache result */ } )
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:26 AM
    Is this because there are a bunch of attributes on the element that will need to be included in the request?
  • m

    mysterious-toddler-20573

    12/24/2020, 3:26 AM
    yes
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:27 AM
    (damn)
  • m

    mysterious-toddler-20573

    12/24/2020, 3:27 AM
    we need to collect any variables, etc.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:27 AM
    header, any event processing, etc.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:27 AM
    I think we need the whole shebang
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:27 AM
    Yes, I agree with the whole shebang.
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:29 AM
    Now that we're here, for this use case it would be good if we DIDN'T process the response headers.
    HX-Push
    ,
    HX-Redirect
    ,
    HX-Refresh
    would all cause havoc if we're preloading page fragments. I may have asked for more than I bargained for.
  • g

    gorgeous-ghost-95789

    12/24/2020, 3:30 AM
    An alternative might be to fake the
    HX-Request
    header into my extension code, but that feels even more icky.
  • m

    mysterious-toddler-20573

    12/24/2020, 3:32 AM
    Yes, of course
  • m

    mysterious-toddler-20573

    12/24/2020, 3:33 AM
    With the empty onload handler, you would ignore all that
  • m

    mysterious-toddler-20573

    12/24/2020, 3:33 AM
    You'd get everything except the response handling, which I think is the right thing (ish)
  • m

    mysterious-toddler-20573

    12/24/2020, 3:34 AM
    does the http cache take request headers into consideration?
1...109110111...1146Latest