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

    bland-rainbow-1285

    05/19/2023, 8:53 AM
    Found the solution : HX-Retarget (If error change the target to any other element if success then return the new form)
  • g

    gray-zebra-72301

    05/19/2023, 9:32 AM
    Hello. Is there a way to show content loaded with htmx only after an image included in the response has finished loading?
  • q

    quiet-cartoon-75498

    05/19/2023, 10:17 AM
    Hi! I believe this example shows that? https://htmx.org/examples/lazy-load/
  • g

    gray-zebra-72301

    05/19/2023, 10:51 AM
    This is not exactly what I need. I am loading content into an overlay (these are spots on a map) that besides some html, contains a small image. The html is rendered inside the overlay, but the included
    img
    is naturally loading a bit late. I want to show the whole overlay's content when this image has finished loading.
  • a

    astonishing-cpu-59399

    05/19/2023, 11:11 AM
    @mysterious-toddler-20573
  • s

    stocky-dentist-80693

    05/19/2023, 11:33 AM
    If you give the form an ID, you should be able to place inputs or buttons outside the form tag, as long as you add the
    form
    attribute to them to indicate it belongs to the form. E.g.
    <button type="submit" form="id_of_login_form">
  • s

    stocky-dentist-80693

    05/19/2023, 11:35 AM
    This is standard html behaviour, btw - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form
  • g

    great-cartoon-12331

    05/19/2023, 2:04 PM
    if it's supposed to get the page on load, then it's not really clickable anyway, so why even use an
    <a>
    tag?
  • e

    eager-plumber-49649

    05/19/2023, 4:33 PM
    Would a PR be welcome to send a JSON body when htmx.ajax is called with a CT JSON header?
  • f

    fancy-account-70160

    05/19/2023, 6:29 PM
    Not sure if you are still figuring this out but what I did to update a plotly graph was to send the data with the following format using hx-get. I was updating the whole graph until I figured this out, you can check it out on jayaro.dev/aurora, mind you I'm in my early stages of redoing my Dash App.
    Copy code
    <script type="text/javascript">
        var data = {
            x: [{time_tag}],
            y: [{bz}]
            };
        Plotly.update("div2", data);
        </script>
  • f

    fancy-account-70160

    05/19/2023, 6:37 PM
    Hi there! Awesome framework! I'm a total noob, I'm wondering if anybody has tried to capture the data points from a plotly graph using HTMX. I found the javascript to be able to get them but unsure how to pass it to a post request.
    Copy code
    document.getElementsByClassName('js-plotly-plot')[0].on('plotly_click', function(data) {console.log(data)})
  • v

    victorious-lamp-70479

    05/19/2023, 6:37 PM
    you can write code between 2 `
  • v

    victorious-lamp-70479

    05/19/2023, 6:38 PM
    document.etc...
  • q

    quick-lamp-41411

    05/19/2023, 6:38 PM
    You can use
    htmx.ajax
  • v

    victorious-lamp-70479

    05/19/2023, 6:38 PM
    or
    Copy code
    js
    document.getElementsByClassName('js-plotly-plot')[0].on('plotly_click', function(data) {console.log(data)})
  • v

    victorious-lamp-70479

    05/19/2023, 6:38 PM
    😉
  • f

    fancy-account-70160

    05/19/2023, 6:51 PM
    @victorious-lamp-70479 @quick-lamp-41411 Thanks! I fixed the code blocks and I will try with htmx.ajax hopefully I don't get owned by lack of front end skills
  • v

    victorious-lamp-70479

    05/19/2023, 6:57 PM
    other tip, for have the colored syntax, you can do ```
  • v

    victorious-lamp-70479

    05/19/2023, 6:58 PM
    and then close after your code```
  • r

    red-farmer-97020

    05/20/2023, 4:23 AM
    Hm, I'm seeing a bit of strange behavior I'd like to avoid when using HTMX - I have a form that does a GET onChange which will swap in values. The issue is that the swap (even if the values are the same) seems to trigger onChange again? But with no query parameters?
  • r

    red-farmer-97020

    05/20/2023, 4:26 AM
    eg I see the first request happens on the first onChange, then the second request happens which seems to cause a third request, but then the value is reset for some reason. I'm starting to think the dom swap strategy is a problem, going to try idiomorph instead

    https://cdn.discordapp.com/attachments/725789747212976259/1109336227360030821/image.pngâ–¾

  • r

    red-farmer-97020

    05/20/2023, 4:28 AM
    yep seems to work fine with idiomorph 😃
  • r

    red-farmer-97020

    05/20/2023, 4:46 AM
    Only remaining issue is that with poor networking conditions, the values of my form inputs are getting reset
  • r

    red-farmer-97020

    05/20/2023, 4:47 AM
    since by the time the swap happens the user will have typed in more input - are there any workarounds to that?
  • r

    red-farmer-97020

    05/20/2023, 5:14 AM
    I guess I should back up a bit - I have a dropdown that changes the number of inputs below it based on what the user selects. How can I ensure that if the dropdown is toggled (which submits a get request with the current value of the form) and I change one of the form inputs while the request is pending, when the request completes I don't swap in a "stale" input value?
  • s

    shy-zebra-22292

    05/20/2023, 6:09 AM
    I am not sure I get what exactly you're doing. But did you try to put unique #id on each of the html tags you want to preserve the state of?
  • r

    red-farmer-97020

    05/20/2023, 6:15 AM
    so event with idiomorph and unique ids if I swap an element that is being edited htmx will use the value from the server rather than the value on the client
  • r

    red-farmer-97020

    05/20/2023, 6:16 AM
    so with throttling enabled in dev tools, I end up with the value of the input changing out from under me
  • s

    shy-zebra-22292

    05/20/2023, 6:22 AM
    I am even more confused by what you wrote now. Is that a question or a statement? 😄
  • r

    red-farmer-97020

    05/20/2023, 6:23 AM
    let me explain what I want to do again haha: 1. I have a dropdown with two options, either A or B 2. When A is selected, I want there to be three inputs rendered 3. When B is selected, I want there to be five inputs rendered The issue I'm running into is what happens when the latency is high enough for me to select A, and then start typing into the existing inputs. Those changes end up being lost by the time the request comes back and swaps the HTML
1...113411351136...1146Latest