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

    hundreds-camera-24900

    12/31/2022, 8:00 PM
    you can use hx-vals to specifically state what data should be sent against the wire
  • h

    hundreds-camera-24900

    12/31/2022, 8:01 PM
    actually https://htmx.org/attributes/hx-params/ is probably a better fit
  • i

    important-cricket-63511

    12/31/2022, 8:15 PM
    Doh. Don't know how i missed that. Thank you @hundreds-camera-24900 !
  • h

    hundreds-camera-24900

    12/31/2022, 8:15 PM
    np 🙂
  • w

    wonderful-school-81222

    12/31/2022, 8:15 PM
    Is there any reason why I wouldn’t get a POST body? I get headers but no body.
  • h

    hundreds-camera-24900

    12/31/2022, 8:16 PM
    no form data to submit?
  • w

    wonderful-school-81222

    12/31/2022, 8:16 PM
    Ohhhh
  • w

    wonderful-school-81222

    12/31/2022, 8:16 PM
    So I have input element inside a form. But I trigger on key up
  • w

    wonderful-school-81222

    12/31/2022, 8:17 PM
    Does hx-post require a method that responds to a form submit?
  • h

    hundreds-camera-24900

    12/31/2022, 8:18 PM
    no that sounds right to me
  • h

    hundreds-camera-24900

    12/31/2022, 8:18 PM
    you have hx-post on the form?
  • h

    hundreds-camera-24900

    12/31/2022, 8:18 PM
    and h-xtrigger: keyup
  • h

    hundreds-camera-24900

    12/31/2022, 8:18 PM
    it should post all the inputs inside of it
  • h

    hundreds-camera-24900

    12/31/2022, 8:18 PM
    can you post an html snippet?
  • w

    wonderful-school-81222

    12/31/2022, 8:26 PM
    Copy code
    html
    <form id="search-form" class="relative">
        <i class="absolute bi bi-search text-gray-400 top-4 left-4"></i>
        <input id="phraseDiv" type="search" hx-post="search_result" hx-trigger="keyup changed delay:1s"
            hx-target="#search-results"
            class="bg-white h-14 w-full px-12 rounded-lg focus:outline-none hover:cursor-pointer">
    </form>
  • w

    wonderful-school-81222

    12/31/2022, 8:27 PM
    I have hx-post on the input element
  • h

    hundreds-camera-24900

    12/31/2022, 8:29 PM
    try adding a name atribute to the input
  • h

    hundreds-camera-24900

    12/31/2022, 8:30 PM
    i think right now it doesn't know what the send the data in #phraseDiv back the server as
  • w

    wonderful-school-81222

    12/31/2022, 8:32 PM
    Yep. That gives me something in the body
    Body: b'search='
  • w

    wonderful-school-81222

    12/31/2022, 8:33 PM
    But I don't get anything in the value.
  • w

    wonderful-school-81222

    12/31/2022, 8:34 PM
    I also tried using hx-include="#myform" to see if it would post the entire form up with the appropriate values.
  • h

    hundreds-camera-24900

    12/31/2022, 8:35 PM
    try moving the hx-post up to the form?
  • w

    wonderful-school-81222

    12/31/2022, 8:37 PM
    That no longer calls my endpoint.
  • l

    limited-potato-46306

    12/31/2022, 8:42 PM
    I have a question about form validation - the difference between drop and abort. In the docs (https://htmx.org/attributes/hx-sync/) there are 2 examples.
    Copy code
    <form hx-post="/store">
        <input id="title" name="title" type="text" 
            hx-post="/validate" 
            hx-trigger="change"
            hx-sync="closest form:abort">
        <button type="submit">Submit</button>
    </form>
    And
    Copy code
    <form hx-post="/store">
        <input id="title" name="title" type="text" 
            hx-post="/validate" 
            hx-trigger="change"
            hx-sync="closest form:drop"
        >
        <button type="submit">Submit</button>
    </form>
    In the first example, the docs say that if there were a validation request and a form submission, the validation request would be cancelled and the form submission would be prioritized. In the second example, the validation would be prioritized and the form submission would be dropped. Both examples use "form:drop" or "form:abort". In both cases, wouldn't the form submission be cancelled? Don't both actions operate on the form, not on the input?
  • w

    wonderful-school-81222

    12/31/2022, 10:19 PM
    And changing to hx-get didn't work either.
  • s

    some-solstice-89459

    12/31/2022, 10:34 PM
    try specifying the method to post in the form
  • w

    wonderful-school-81222

    12/31/2022, 10:35 PM
    In this Active Search example where hx-trigger is defined as:
    Copy code
    html
    hx-trigger="keyup changed delay:500ms, search"
    What does the term at the end called "search" do?
  • s

    some-solstice-89459

    12/31/2022, 10:35 PM
    when an event with the name of search is emitted the form is submitted
  • w

    wonderful-school-81222

    12/31/2022, 10:36 PM
    I thought I did that correctly with
    hx-post="search_result"
  • w

    wonderful-school-81222

    12/31/2022, 10:37 PM
    In the Active Search example they do not use a form: https://htmx.org/examples/active-search/
1...964965966...1146Latest