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

    mysterious-toddler-20573

    10/29/2022, 6:51 PM
    e.g. leave the top menu or whatever alone
  • b

    brainy-ice-92385

    10/29/2022, 6:55 PM
    I don't know if this helps with this sitch, not looking at the code w u, but I was recently considering smalltalk-like returns by passing a promise in the detail of an event. So you make an unresolved promise, send it in the event, then await the promise. Then a handler somewhere can resolve it. This is tricky in JS but I have a solution if you're interested (again idk if it helps this usecase)
  • m

    mysterious-toddler-20573

    10/29/2022, 6:58 PM
    grug getting what grug deserve
  • b

    bitter-machine-55943

    10/29/2022, 11:31 PM
    CSS selectors can be attributes. New possibilities emerge 😈
  • m

    mysterious-toddler-20573

    10/30/2022, 1:54 AM
    OK, looking at this more
  • m

    mysterious-toddler-20573

    10/30/2022, 1:54 AM
    the best cut point I can see is the
    htmx:beforeSend
    event
  • m

    mysterious-toddler-20573

    10/30/2022, 1:55 AM
    ugh
  • m

    mysterious-toddler-20573

    10/30/2022, 1:55 AM
    no, there is a lock in there
  • m

    mysterious-toddler-20573

    10/30/2022, 1:55 AM
    man
  • m

    mysterious-toddler-20573

    10/30/2022, 1:56 AM
    javascript, why can't you be hyperscript
  • b

    bitter-machine-55943

    10/30/2022, 2:09 AM
    Is it more efficient to use
    defineExtension
    with
    init
    and
    htmx.on
    for the events you want, vs using
    onEvent
    and checking for the event types with
    if
    ?
  • m

    mysterious-toddler-20573

    10/30/2022, 2:11 AM
    onEvent will be called when the extension annotation is above the element in question, htmx.on() will be global (unless you scope it somehow)
  • b

    bitter-machine-55943

    10/30/2022, 2:15 AM
    Ah ok. So you were going for global with htmx.on() in head-support
  • m

    mysterious-toddler-20573

    10/30/2022, 2:18 AM
    Yeah, it's a singleton
  • m

    mysterious-toddler-20573

    10/30/2022, 2:18 AM
    but OTOH, I wasn't thinking deeply
  • m

    mysterious-toddler-20573

    10/30/2022, 2:18 AM
    (that's my secret, cap)
  • b

    bitter-machine-55943

    10/30/2022, 2:49 AM
    I need to watch more Marvel movies
  • b

    bitter-machine-55943

    10/30/2022, 3:04 AM
    Is the outgoing HTML chunk stored in the event for
    htmx:afterSwap
    ?
  • r

    red-dinner-66239

    10/30/2022, 11:07 AM
    hello i have a little question i use htmx to refresh my page and have my data always up to date but the thing is that when i open a popup 5s later it closes because of the refresh of the page how can i fix this problem can there be a way to tell him that when i click on my button the htmx is deactivated? but then how 😅
  • b

    bitter-monkey-50309

    10/30/2022, 2:00 PM
    Take a look at the
    htmx:beforeRequest
    or
    htmx:beforeSend
    events. You can write a little bit of Javascript (or hyperscript) to check if the popup is open and if it is use
    htmx:abort
    to cancel the request
  • b

    boundless-vase-80440

    10/30/2022, 2:33 PM
    just had to move it outside the element being updated.
  • r

    ripe-action-67367

    10/30/2022, 3:37 PM
    https://htmx.org/attributes/hx-preserve/
  • m

    modern-wall-92403

    10/30/2022, 5:17 PM
    I can't seem to find the multi-swap extension. Is it available somewhere? https://unpkg.com/browse/htmx.org@1.8.2/dist/ext/
  • c

    cuddly-keyboard-70746

    10/30/2022, 5:26 PM
    you don't find the multi-swap extension. The multi-swap extension finds you
  • c

    cuddly-keyboard-70746

    10/30/2022, 5:28 PM
    @mysterious-toddler-20573 it really does seem to be missing. this page has a link to the extension and it can't find it https://htmx.org/extensions/multi-swap/
  • m

    modern-wall-92403

    10/30/2022, 5:34 PM
    This answer says I can use a class selector to replace the contents of multiple targets, but on testing only the first element with the class is changed: https://stackoverflow.com/questions/73206031/can-hx-select-oob-update-several-targets
  • b

    bitter-machine-55943

    10/30/2022, 6:06 PM
    Is there a reason some extensions only have
    htmx.defineExtension(…)
    while others are wrapped in
    (function(){…})()
    ?
  • b

    bitter-machine-55943

    10/30/2022, 6:23 PM
    I guess one the single
    htmx.defineExtension
    call doesn’t add anything to the global namespace, and wrapping in
    (function()…)()
    is used when variables are created but you don’t want to pollute the global namespace?
  • m

    mysterious-toddler-20573

    10/30/2022, 6:27 PM
    I use the
    (function(){.. })()
    form when I want to have some shared state across all the extension points. That's the old school JavaScript trick for that.
  • m

    mysterious-toddler-20573

    10/30/2022, 7:00 PM
    looks like I screwed up and added the docs to master, but the extension is still in dev: https://github.com/bigskysoftware/htmx/blob/dev/src/ext/multi-swap.js
1...882883884...1146Latest