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

    quick-crayon-19412

    02/17/2023, 4:01 PM
    The thing is the input doesn't actually change other than it was focused and then not.
  • w

    white-rocket-20067

    02/17/2023, 4:11 PM
    Not sure if this applies to your situation but in your hx-post you can add an anchor to the url. That way you can keep focus on the element that initiates the request. Check out https://beschikbaarheid.heerenveen.nl/ for an example. Gotta run now.
  • l

    limited-teacher-83117

    02/17/2023, 5:31 PM
    I could have sworn I did this in the past, but I can't find it now: is there a simple way to scroll to the top of a replaced element? i.e. I'm clicking the submit button in a form, and it replaces the submitted form with a new element, can I get the browser to scroll to the beginning of the new element?
  • m

    mysterious-toddler-20573

    02/17/2023, 5:34 PM
    https://htmx.org/attributes/hx-swap/
  • m

    mysterious-toddler-20573

    02/17/2023, 5:35 PM
    sounds like you want
    show:top
  • l

    limited-teacher-83117

    02/17/2023, 6:25 PM
    That's it, thank you!
  • e

    enough-petabyte-50314

    02/17/2023, 7:39 PM
    Is there a way to ensure our JS runs after HTMX has processed things? Context: We want to change the hx-get of an element based on the # of the url, then trigger that element's hx-get.. but we're not seeing anything happen at all. I assume this means htmx hasn't prepared that node yet, but not sure
  • e

    enough-petabyte-50314

    02/17/2023, 7:44 PM
    do i have to call
    htmx.process
    after changing the element's
    hx-get
    attribute? or is there a better way to change what url is got?
  • e

    enough-petabyte-50314

    02/17/2023, 7:47 PM
    doing that ^ does work.. i.e.
    Copy code
    element.setAttribute('hx-get', newPath);
    htmx.process(element);
    htmx.trigger(element, 'someevent');
  • e

    enough-petabyte-50314

    02/17/2023, 7:51 PM
    Hmm. looks like https://htmx.org/api/#ajax is probably what I want actually
  • e

    enough-petabyte-50314

    02/17/2023, 7:53 PM
    Copy code
    htmx.ajax('GET', newPath, {target: '#whatever', swap: 'innerHTML'});
    yeah.. this seems right
  • m

    mysterious-car-3675

    02/17/2023, 9:26 PM
    I'm new to htmx and i keep hitting "well how would i do X". Right before I start a message on here I just stare at the htmx attributes. Not even looking at the contents, just the links. Then I feel dumb, do the simplest thing and move on. Its liking rubberduck driven development but somehow dumber.
  • h

    happy-knife-63802

    02/17/2023, 9:42 PM
    It makes a lot more sense when you just start using it
  • h

    happy-knife-63802

    02/17/2023, 9:42 PM
    You have to adjust your mindset a bit
  • b

    brainy-grass-55742

    02/17/2023, 10:51 PM
    All right. Another week I resisted the urge to download jquery and do it the old way. 🙂 HTMX for the win!!
  • a

    able-secretary-52593

    02/18/2023, 1:16 PM
    What's the difference between`hx-vals` and the
    include-vals
    extension?
  • r

    ripe-action-67367

    02/18/2023, 1:35 PM
    syntax
  • r

    ripe-action-67367

    02/18/2023, 1:38 PM
    also, hx-vals was added after include-vals, so most likely it is kept for compatibility
  • r

    refined-manchester-67193

    02/18/2023, 10:27 PM
    Any ideas on how to deal with
    hx-trigger="revealed"
    getting missed due to very fast scrolling or a refresh when at the bottom of the page (which would skip the to-be-revealed item). Context: I'm building an infinite-scroll feed with a catch - I don't want the last item to trigger the next batch, I want it a bit before.
  • m

    mysterious-toddler-20573

    02/18/2023, 10:36 PM
    might be worth implementing your own javascript logic if the current logic isn't catching it
  • r

    ripe-action-67367

    02/18/2023, 10:48 PM
    It's tiny bit hacky, but here is an idea
  • r

    refined-manchester-67193

    02/18/2023, 11:28 PM
    yeah that's exactly what I'm doing, basically for N items I'm putting the
    hx-get + hx-trigger=revealed
    on the
    N-X
    item which gives a little head start to load the next items. Unfortunately sometimes
    htmx
    is missing that the item has been revealed.
  • r

    ripe-action-67367

    02/18/2023, 11:31 PM
    That's what I thought. My idea is to put a wrapper div over last X items, not just N-X item, so that hx-get is triggered if any of the last item is revealed, event if the user scroll past N-X item quickly
  • r

    ripe-action-67367

    02/18/2023, 11:32 PM
    This might break the layout, obviously, but it's the simplest option I can think of
  • r

    ripe-action-67367

    02/18/2023, 11:49 PM
    Alternatively, you could make a hidden empty div with absolute positioning to keep elements flow intact
  • r

    refined-manchester-67193

    02/19/2023, 12:49 AM
    Yeah a wrapper would break the layout, but the absolute positioned element might do it. I’ll have to calculate how many elements I have left between N-X and N to determine its height I guess. Thanks @ripe-action-67367
  • s

    some-airline-73512

    02/19/2023, 4:16 PM
    How to delete element with
    hx-swap-oob=true
    in response?
  • r

    ripe-action-67367

    02/19/2023, 4:47 PM
    hx-swap-oob=delete
  • r

    ripe-action-67367

    02/19/2023, 4:48 PM
    hx-swap-oob accepts any valid hx-swap value https://htmx.org/attributes/hx-swap-oob/ https://htmx.org/attributes/hx-swap/
  • s

    some-airline-73512

    02/19/2023, 5:10 PM
    Great, thank you very much
1...102410251026...1146Latest