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

    happy-knife-63802

    08/20/2022, 10:40 AM
    Sure.. using something like this:
    Copy code
    <form method=“POST”>
    <input type=“text” required pattern=“[0-9]*” hx-post=“/validate-something” hx-trigger=“click”>
    </form>
    Html5 validation doesn’t kick in and the required and pattern attributes are ignored, allowing the post request to go through. In your thread on issues you debated this with someone else and said that you would expect this behaviour rather so that server side validation could happen without browser interference, which I agree is the right approach. But I can’t get the html5 validation to kick in at all. Any ideas?
  • h

    happy-knife-63802

    08/20/2022, 10:41 AM
    Sorry that should have been keyup changed not click
  • h

    happy-knife-63802

    08/20/2022, 10:42 AM
    The correct hx-trigger I’m using is ‘keyup changed delay:1000ms, blur delay:100ms’
  • h

    happy-knife-63802

    08/20/2022, 10:42 AM
    In either case it wont check for the required attrib and the empty value is submitted
  • h

    happy-knife-63802

    08/20/2022, 10:47 AM
    I’m guessing this is because only the submit event calls checkvalidity?
  • g

    great-midnight-35149

    08/20/2022, 11:28 AM
    I ran into the same thing and yes, it needs to be the submit event in order for the browser to check validity before posting.
  • h

    happy-knife-63802

    08/20/2022, 11:44 AM
    Were you able to find a way around it?
  • h

    happy-knife-63802

    08/20/2022, 11:45 AM
    I know some hs or alpine can do it fairly easily but I’m asking here because of the GitHub issue and the [valid] filter which would make life far less … complex
  • g

    great-midnight-35149

    08/20/2022, 11:57 AM
    I had to move on with just waiting for the submit, but I'm going to come back using a similar approach to this post http://hernantz.github.io/inline-form-validation-with-django-and-htmx.html
  • e

    echoing-nest-31408

    08/20/2022, 1:55 PM
    Is there a way to have htmx set hx-target to one value when hx-trigger is input, but a different hx-target when the hx-trigger is submit? Trying to work out the best way to get around some user experience issues I'm hitting. Another potential solution I tried is having in the form with the hx-target I want with hx-trigger being click, but when I do that the form POST data doesn't include the button's value.
  • e

    echoing-nest-31408

    08/20/2022, 2:01 PM
    Easiest is for me to just replace the whole form, but if I use hx-trigger of "input delay:1s", and a user is in an input with cursor at the end of that input's content, then when the content div is replaced, the cursor is moved to the start of that input.
  • m

    mysterious-toddler-20573

    08/20/2022, 4:16 PM
    You can put the hx-get or whatever on two different elements and have them target different things
  • m

    mysterious-toddler-20573

    08/20/2022, 4:16 PM
    You could also use the morphdom extension which should do a better job of preserving focus and caret position
  • h

    hallowed-architect-39752

    08/20/2022, 7:51 PM
    so what's the deal with calling things "microservices"? I get the gist that they're supposed to be loosely-coupled but isn't that just generally good programming practices?
  • m

    mysterious-toddler-20573

    08/20/2022, 7:53 PM
    a microservice is deployed separately
  • m

    mysterious-toddler-20573

    08/20/2022, 7:53 PM
    often runs "serverless", which, in my experience, means: "I don't know how this runs"
  • m

    mysterious-toddler-20573

    08/20/2022, 7:54 PM
    but, in fact, if i understand correctly, means: "runs in a vm-based server managed by amazon in an opaque manner"
  • h

    hallowed-architect-39752

    08/20/2022, 7:55 PM
    whereas a monolith is deployed as a single "instance"?
  • m

    mysterious-toddler-20573

    08/20/2022, 7:55 PM
    correct
  • m

    mysterious-toddler-20573

    08/20/2022, 7:56 PM
    imo microservices conflate (at least) three things: proper system decomposition, deployment and scaling. A lot of people appeal to Conway's Law regarding them: each department or developer gets their own independent development environment, through deploy.
  • m

    mysterious-toddler-20573

    08/20/2022, 7:56 PM
    suffice to say, I am not a fan
  • h

    hallowed-architect-39752

    08/20/2022, 7:57 PM
    thanks for the explanation. seems like the notion of microservices is pretty vague
  • m

    mysterious-toddler-20573

    08/20/2022, 7:57 PM
    yes
  • m

    mysterious-toddler-20573

    08/20/2022, 7:57 PM
    i don't mind macroservices
  • m

    mysterious-toddler-20573

    08/20/2022, 7:58 PM
    a database is a macroservice
  • m

    mysterious-toddler-20573

    08/20/2022, 7:58 PM
    something like a system that is responsible for all email delivery, fine
  • m

    mysterious-toddler-20573

    08/20/2022, 7:59 PM
    but microservices seem to be addressing an admitted problem: deploying multiple changes across an org is hard, by making it really hard to refactor across the code base.
  • m

    mysterious-toddler-20573

    08/20/2022, 7:59 PM
    and the deployment, monitoring, etc. all ends up getting pretty crazy anyway
  • m

    mysterious-toddler-20573

    08/20/2022, 8:00 PM
    anyway, I'm not a fan, but I am old and grumpy
  • m

    mysterious-toddler-20573

    08/20/2022, 8:00 PM
    not to say it's always inappropriate, but I lean monolith by default
1...788789790...1146Latest