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

    mysterious-toddler-20573

    03/14/2023, 1:21 AM
    there is a pull request out for it, but I haven't accepted it yet
  • g

    gentle-salesclerk-37089

    03/14/2023, 2:20 AM
    I'm still unsure how to best represent the whole "resource state" problem in htmx
  • g

    gentle-salesclerk-37089

    03/14/2023, 2:21 AM
    that is, NOT_REQUESTED, LOADING, FAILED(error), SUCCESS(data)
  • g

    gentle-salesclerk-37089

    03/14/2023, 2:21 AM
    specifically the failed case. In all the things i've done so far with htmx failure just means unresponsive unless i am catching something in the server and explicitly rendering error html or wtvr
  • g

    gentle-salesclerk-37089

    03/14/2023, 2:21 AM
    its nowhere near a blocker for the work i do, just a thing
  • m

    mysterious-toddler-20573

    03/14/2023, 2:31 AM
    we trigger some events that you can handle: https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L2920
  • r

    refined-manchester-67193

    03/14/2023, 8:31 AM
    I think I’m experiencing a different issue. Will upload a repro video in a bit.
  • a

    acceptable-father-23552

    03/14/2023, 2:06 PM
    does htmx work with control?
  • t

    tall-dinner-62086

    03/14/2023, 3:27 PM
    Define "works with". What do you want htmx to do with that input?
  • a

    acceptable-father-23552

    03/14/2023, 3:28 PM
    i replaced the datalist associated with the control but its values did not change
  • a

    acceptable-father-23552

    03/14/2023, 3:29 PM
    the time control
  • t

    tall-dinner-62086

    03/14/2023, 3:30 PM
    Hard for me to test that since firefox doesn't support datalists for time inputs
  • a

    acceptable-father-23552

    03/14/2023, 3:33 PM
    hmmm.. so it may be better to just use a dropdown list?
  • t

    tall-dinner-62086

    03/14/2023, 3:35 PM
    Testing with a text input, I can swap datalists on the fly and it works fine
  • t

    tall-dinner-62086

    03/14/2023, 3:36 PM
    try swapping the type to time and see if it works on whatever browser you're using that isn't firefox
  • a

    acceptable-father-23552

    03/14/2023, 3:41 PM
    Thank you.. Am investigating 👍
  • a

    acceptable-father-23552

    03/14/2023, 3:46 PM
    Your example works.. I guess I need to swap the outerHtml
  • a

    acceptable-father-23552

    03/14/2023, 3:46 PM
    I was only changing the innerHtml
  • a

    acceptable-father-23552

    03/14/2023, 3:48 PM
    no.. that is not it
  • a

    acceptable-father-23552

    03/14/2023, 3:49 PM
    innerHtml still works in your example
  • a

    acceptable-father-23552

    03/14/2023, 3:52 PM
    I was able to make it work.. My time format was missing the leading 0
  • l

    limited-teacher-83117

    03/14/2023, 4:25 PM
    HTMX is not particularly opinionated on error handling (which I think is something that it would be nice to build on, over time) but the way I've handled it is by including a small config file in my head template, right below where I import HTMX
    Copy code
    js
    
    document.addEventListener('DOMContentLoaded', function () {
      document.body.addEventListener('htmx:beforeSwap', function (evt) {
        const status = evt.detail.xhr.status
        if (status === 400 || status === 500) {
          // Stops the error from logging in the console
          evt.detail.isError = false
    
          // Create an error dialog box
          const errorDialog = document.createElement('div')
          errorDialog.classList.add('error-message')
          errorDialog.innerText = evt.detail.serverResponse
          errorDialog.setAttribute('onclick', 'this.remove()')
    
          // Get the nav and place the element after it
          const nav = document.querySelector('.site-nav')
          nav.insertAdjacentElement('afterend', errorDialog)
          errorDialog.scrollIntoView()
        }
      })
    })
    I think I adapted this from the documentation somewhere. There's some room for improvement (what if it errors twice?) but it's one basic way to hook in
  • r

    refined-manchester-67193

    03/14/2023, 4:55 PM
    So as I said I think I’m experiencing a different kind of bug. Repro video is up here: https://www.dropbox.com/s/tois6kye5nqr8dl/repro.mov?dl=0 As you can see I bring up a modal that is loaded via HTMX, when I click the “Apply” button, I admittedly do some HyperScript and htmx magic to update the page’s URL. So now a new grid is loaded via HTMX and I click a regular plain href link to go to another page, when I hit the back button, it seems that HTMX “remembers” that last request was made by it (?), and so the site is completely unstyled as you can see. As I said I have cacheSize set to 0, and it has always been like that on this machine. I’ve also tested this incognito. I mean, what could make the request still go through the history like that?
  • r

    refined-manchester-67193

    03/14/2023, 5:07 PM
    Hmmm, am looking for
    refreshOnHistoryMiss=true
    here? EDIT: Never mind, tried that, didn't work
  • r

    refined-manchester-67193

    03/14/2023, 5:21 PM
    It seems like Chrome wants to load the latest ("cached") response it got from the HTMX request, but that's a horrible idea in this case since that is only a partial response so it just fails...? really struggling to understand what's going on.
  • m

    mysterious-toddler-20573

    03/14/2023, 5:24 PM
    Maybe you are running into the
    Vary
    issue described here: https://htmx.org/docs/#caching
  • b

    bulky-kilobyte-96254

    03/14/2023, 5:27 PM
    What response header should I use if I just want a full page refresh to another URL?
  • r

    refined-manchester-67193

    03/14/2023, 5:31 PM
    Nah, I'm sorry to waste everybody's time but this was the problem:
    Copy code
    document.addEventListener("DOMContentLoaded", function (event) {
    htmx.config.historyCacheSize = 0;
    }
    Apparently this sometimes might not run "...because the DOMContentLoaded event was already fired at this point." (source: https://stackoverflow.com/a/39993724/5013234)
  • b

    bulky-kilobyte-96254

    03/14/2023, 5:33 PM
    Combination of
    HX-Refresh
    and
    HX-Redirect
    seems to work, but only if the status code is >=400
  • e

    eager-plumber-49649

    03/14/2023, 5:48 PM
    Hi, I found
    keyup changed
    does not work when used with a css selector like
    keyup changed from:#something
    or
    keyup from:#something changed
    (not sure which would actually by correct). It works when used like
    keyup from:#something
    though, that's strange. Another event that could be documented as alternative to
    keyup changed
    is
    input
    . 🙂 It fires when input changed. It also works when used like
    input from:#something
1...106510661067...1146Latest