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

    strong-machine-53662

    05/20/2023, 2:51 PM
    And how would those "Islands" be embedded into my Go + HTMX for example?
  • s

    strong-machine-53662

    05/20/2023, 2:51 PM
    I would invoke a request from React app, and render the content inside the island?
  • r

    red-farmer-97020

    05/20/2023, 2:59 PM
    This does technically work for my app, but I am trying to come up with a more general solution for complicated forms haha. In those cases I'm trying to move form validation and dynamicness to the backend language I work with.
  • Improvements
    r

    red-farmer-97020

    05/20/2023, 3:19 PM
    I think the most ideal solution is the last example of https://htmx.org/attributes/hx-sync/, but even that example has a bug where latency can cause input to be overwritten
    m
    • 2
    • 9
  • r

    red-farmer-97020

    05/20/2023, 3:26 PM
    I think what I want is a
    throttle
    or
    delay
    on hx-sync that cancels in flight requests the moment any input has taken place, but doesn't send a new request until the throttle or delay has finished. I think that guarantees no input be overwritten due to latency
  • s

    shy-zebra-22292

    05/20/2023, 3:44 PM
    well yes.. you can get server-rendered react or just load the js and attach it to a specific DIV to do it's job. https://www.patterns.dev/posts/islands-architecture You can also accomplish a good amount by using Alpine.js that plays well with HTMX (has plugin for it afaik) and does much of what React does without the compilation and having a ReactApp server at all. https://alpinejs.dev/ of course if you really have to you're free to use react πŸ™‚
  • s

    strong-machine-53662

    05/20/2023, 3:45 PM
    Thank you very much! I'm a full stack dev, and I'm kinda sick of hearing words like
    State Management
    ,
    hooks
    and so on πŸ˜„ I'm pretty excited to give this a go
  • s

    shy-zebra-22292

    05/20/2023, 3:47 PM
    I am the same way. (already giving it a go...) spent the last 6 years in full or partial work in Vue and Angular :3 They are an overkill almost all the time. Even the apps that DO need a reactive framework don't need it all over the place.
  • s

    strong-machine-53662

    05/20/2023, 3:50 PM
    Yep, this is also how I feel πŸ˜„
  • Favorite Framework For Working With Forms and HTMX
    g

    gray-rocket-3571

    05/20/2023, 5:22 PM
    Playing around with Django, htmx, and crispy-forms and Django-forms-dynamic to do some pretty neat form stuff (demo/write up a few weeks out - but like individual field changes trigger interactions with other parts of the form). I don’t know any other frameworks other than Django; what are your experiences with robustness of forms and form libraries in other languages and frameworks?
    g
    s
    • 3
    • 3
  • h

    hundreds-jordan-64279

    05/21/2023, 5:06 AM
    what's the recommended pattern when you need a change in one element to launch get requests (same data, a UUID) to another two separate elements? I figure I can only set one hx-target
  • g

    great-cartoon-12331

    05/21/2023, 5:07 AM
    you can update more than one target with the same response fragment: https://htmx.org/attributes/hx-swap-oob/
  • h

    hundreds-jordan-64279

    05/21/2023, 5:10 AM
    thanks ! guess I'm a oob noob
  • s

    shy-zebra-22292

    05/21/2023, 5:11 AM
    Once you know it exists it gets easier πŸ˜‰
  • h

    hundreds-jordan-64279

    05/21/2023, 5:38 AM
    do I format oob like this for multiple elements
    hx-swap-oob="#cssA, #cssB, #cssC"
    ? sorry couldn't find in the docs
  • g

    great-cartoon-12331

    05/21/2023, 5:45 AM
    it depends on what the desired effect is. e.g.
    Copy code
    html
    <div>normal target</div>
    <div id="cssA" hx-swap-oob="true">...</div>
    <div id="cssB" hx-swap-oob="true">...</div>
    <div id="cssC" hx-swap-oob="true">...</div>
  • h

    hundreds-jordan-64279

    05/21/2023, 5:48 AM
    when a new option selected in original dropdown I'm trying to refresh multiple downstream elements with a new ID
  • g

    great-cartoon-12331

    05/21/2023, 5:49 AM
    the id needs to remain stable, that's how the oob mechanism knows what the targets are
  • h

    hundreds-jordan-64279

    05/21/2023, 5:51 AM
    sorry I mean I'm passing the ID (key:val pairs) downstream to a few different targets (which their CSS IDs remain stable). e.g. Select option B, pass ID=B to #cssA, #cssB.
  • h

    hundreds-jordan-64279

    05/21/2023, 6:27 AM
    omg pls disregard, I got it working. oob is amazing, htmx is amazing and I'm never going back
  • s

    shy-zebra-22292

    05/21/2023, 12:26 PM
    https://htmx.org/docs/#oob_swaps https://htmx.org/attributes/hx-swap-oob/ πŸ™‚
  • s

    strong-hydrogen-91524

    05/21/2023, 6:20 PM
    Im having a strange issue with bulmacss modals and oob swap. Basically I would like to return the modal with normal request and update another element with the oob swap. But for some reason the modal gets closed immediately after the oob swap occurs. The element to be swapped already exists in the dom and has unique div id. Any ideas?
  • s

    strong-hydrogen-91524

    05/21/2023, 6:27 PM
    The closing normally occurs with event on a close button
  • g

    great-cartoon-12331

    05/21/2023, 6:42 PM
    try slowing down the settle time of the swapping operation (e.g. 10s) and looking at the elements inspector in your browser to see what htmx is doing with the modal
  • g

    gray-zebra-72301

    05/22/2023, 9:38 AM
    I am trying to add a class to an htmx target after an image included in the ajax response finishes loading. If I log the
    target
    , the class is present, but in the actual DOM it is not:
    Copy code
    js
    const afterSwapHandler = async e => {
      const detail = e.detail;
      const id = detail.elt.id;
      const image = detail.elt.querySelector('header > img');
    
      if (image) await imageLoaded(image);
    
      const target = htmx.find(`#${id}`);
      target.classList.add('loaded');
      console.log(target) // the target contains the 'loaded' class 
    }
    It seems like htmx is removing the added class. How can I keep it?
  • g

    gray-zebra-72301

    05/22/2023, 11:50 AM
    Ok, I should have used the
    afterSettle
    event instead. Problem solved.
  • b

    bland-rainbow-1285

    05/22/2023, 1:03 PM
    I have backend returning html fragment which need to add into body section how can I do that???
  • r

    refined-pillow-25368

    05/22/2023, 1:06 PM
    Did anyone try to use preact with htmx?
  • r

    refined-pillow-25368

    05/22/2023, 1:08 PM
    Or any other small SPA? Because I often got the question what if the requirements need more than htmx / HtmlOverTheWire and I don't know if alpinejs is an alternative for many
  • m

    mysterious-toddler-20573

    05/22/2023, 3:37 PM
    Alpine seems more popular
1...113611371138...1146Latest