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

    mysterious-toddler-20573

    12/02/2020, 3:21 PM
    You can use the hx-target attribute to replace a smaller bit of html https://htmx.org/attributes/hx-target
  • m

    mysterious-toddler-20573

    12/02/2020, 3:30 PM
    I’ll try to make a comprehensive answer on stack overflow for you. On phone right now
  • b

    bland-kite-495

    12/02/2020, 3:31 PM
    Thank you very much. It will be helpfull for other novice users too.
  • m

    mysterious-toddler-20573

    12/02/2020, 3:53 PM
    https://stackoverflow.com/a/65111547/14288140
  • g

    glamorous-honey-42686

    12/04/2020, 9:31 AM
    Is it possible to trigger a custom event with data that will be swapped in instead of doing an ajax request?
  • m

    mysterious-toddler-20573

    12/04/2020, 2:14 PM
    Can you give us some example html?
  • h

    helpful-secretary-3515

    12/04/2020, 4:20 PM
    here come's the changed data
  • h

    helpful-secretary-3515

    12/04/2020, 4:25 PM
    i want to swap, as soon , as the content of "/source" changed. is this the right way? 🙂 i guess not :)=
  • m

    mysterious-toddler-20573

    12/04/2020, 4:48 PM
    If I understand you correctly, you want to change when the content at the URL
    /source
    changes. There are a few ways to do this: 1. You could poll /source with this syntax:
    hx-trigger="every 2s"
    2. You could implement Server Sent Events or WebSockets
  • m

    mysterious-toddler-20573

    12/04/2020, 4:48 PM
    The latter is more complex but might be more efficient
  • m

    mysterious-toddler-20573

    12/04/2020, 4:48 PM
    https://htmx.org/docs/#websockets
  • m

    mysterious-toddler-20573

    12/04/2020, 4:49 PM
    https://htmx.org/docs/#sse
  • m

    mysterious-toddler-20573

    12/04/2020, 4:49 PM
    polling is going to be the easiest way to do it, but also the least efficient (although it usually doesn't matter)
  • b

    big-airline-13935

    12/04/2020, 5:27 PM
    > htmx api functions that expect an element now can accept a string selector instead: > htmx.on('#form', 'htmx:xhr:progress', function(evt) { > htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100) > }); What exactly is the new part here? https://github.com/bigskysoftware/htmx/blob/master/CHANGELOG.md#101---2020-12-04
  • h

    helpful-secretary-3515

    12/04/2020, 5:30 PM
    you are my hero! not just that you give me support here, you invented this great tool HTMX that makes my life better and easier! THANK YOU A LOT !!!
  • m

    mysterious-toddler-20573

    12/04/2020, 5:30 PM
    htmx.on('#form', 'htmx:xhr:progress', function(evt) { htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100) });
  • m

    mysterious-toddler-20573

    12/04/2020, 5:30 PM
    You can pass a id in rather than needing to look an element up
  • b

    big-airline-13935

    12/04/2020, 5:30 PM
    Oh, with
    .on()
    , nice!
  • m

    mysterious-toddler-20573

    12/04/2020, 5:30 PM
    rather than having to call
    htmx.find()
    too
  • b

    big-airline-13935

    12/04/2020, 5:32 PM
    Oooh, so can I now do
    htmx.trigger('#form', 'refresh')
    ?
  • m

    mysterious-toddler-20573

    12/04/2020, 5:32 PM
    yes
  • b

    big-airline-13935

    12/04/2020, 5:32 PM
    Woooot!
  • m

    mysterious-toddler-20573

    12/04/2020, 5:32 PM
    you should be able to
  • b

    big-airline-13935

    12/04/2020, 5:32 PM
    Testing now
  • m

    mysterious-toddler-20573

    12/04/2020, 5:32 PM
    😬
  • m

    mysterious-toddler-20573

    12/04/2020, 5:33 PM
    ah, fug no
  • m

    mysterious-toddler-20573

    12/04/2020, 5:33 PM
    I missed that one
  • m

    mysterious-toddler-20573

    12/04/2020, 5:33 PM
    :/
  • m

    mysterious-toddler-20573

    12/04/2020, 5:33 PM
    1.0.2
  • m

    mysterious-toddler-20573

    12/04/2020, 5:33 PM
    :/
1...838485...1146Latest