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

    busy-tomato-43957

    11/20/2022, 1:29 AM
    I've tried hx-swap=none and hx-swap on the inputs' parent node, and both options behave by resetting the radio after loading the htmx response here's the fragment:
    Copy code
    html
    <fieldset class="filter" hx-swap="this">
        <legend>"Filter"</legend>
        <input type="radio" id="filter-all" name="filter" value="All" checked={ selected_filter == All } hx-post="/todos;filter=All" />
        <label for="filter-all">"All"</label>
        <input type="radio" id="filter-active" name="filter" value="Active" checked={ selected_filter == Active } hx-post="/todos;filter=Active" />
        <label for="filter-active">"Active"</label>
        <input type="radio" id="filter-completed" name="filter" value="Completed" checked={ selected_filter == Completed } hx-post="/todos;filter=Completed" />
        <label for="filter-completed">"Completed"</label>
    </fieldset>
  • m

    mysterious-toddler-20573

    11/20/2022, 3:00 AM
    the radio is reset?
  • m

    mysterious-toddler-20573

    11/20/2022, 3:01 AM
    is the HTML being sent down on the wire what you expect?
  • m

    mysterious-toddler-20573

    11/20/2022, 3:01 AM
    What should happen is that you post to
    /todos
    and then the entire fieldset is re-rendered. As long as the HTML that comes down has the correct option selected, it should work.
  • m

    mysterious-toddler-20573

    11/20/2022, 3:03 AM
    oh, ah, I think the checked attribute needs to be absent on the unselected options. It can't be "false" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio#attr-checked
  • m

    mysterious-toddler-20573

    11/20/2022, 3:03 AM
    Copy code
    checked
    
        A Boolean attribute which, if present, indicates that this radio button is the default selected one in the group.
  • f

    freezing-waitress-26396

    11/20/2022, 5:32 AM
    Yep, this is the classic trap, you shold completely unset the checked attribute
  • v

    victorious-match-64854

    11/20/2022, 12:10 PM
    How can we get HTMLX server side rendering
  • b

    boundless-vase-80440

    11/20/2022, 12:13 PM
    In htmx everything is server side rendered.
  • m

    mysterious-toddler-20573

    11/20/2022, 2:03 PM
    Like the HTML it extends, htmx is just hypermedia. Any HTTP library in any language can speak it.
  • v

    victorious-match-64854

    11/20/2022, 2:04 PM
    But if you disable javascript on the browser side JS will not render
  • m

    mysterious-toddler-20573

    11/20/2022, 2:06 PM
    Yes. Unfortunately the only way to extend HTML on the client side is with JavaScript. I suppose a user plugin would work too, but that's beyond the scope of the project. If you know someone who works on chrome you can ask them to integrate htmx-like functionality into HTML itself, which is where it should be, but until that happy day comes to pass we are, unfortunately, reliant on javascript to fix HTML.
  • v

    victorious-match-64854

    11/20/2022, 2:06 PM
    couldn’t agree more
  • o

    orange-nail-40296

    11/20/2022, 10:49 PM
    Correct my if I am wrong but in your headers you can check if it is htmx request or not and handle accordingly. For instance, you can build out your application using HTML, handle all the form submissions accordingly and then sprinkle on enhancements. That is my strategy with htmx-boost where if there is the htmx header I send back just the body, if not then my app just works*.
  • b

    busy-tomato-43957

    11/21/2022, 12:47 AM
    oh thank you! that must have been it
  • a

    ancient-angle-7831

    11/21/2022, 2:28 AM
    Can you use
    hx-preserve
    while doing a
    hx-swap-oob="true"
    ? Because I can't seem to get it to preserve an element on the page (same component ID)
  • b

    busy-tomato-43957

    11/21/2022, 6:15 AM
    could you change hx-target to swap the children of the element you want to preserve instead of the element itself?
  • a

    ancient-angle-7831

    11/21/2022, 7:07 AM
    Unfortunately, if I do a target swap, the changes become very difficult to manage - it's a very complicated and fluid UI
  • m

    mysterious-toddler-20573

    11/21/2022, 1:41 PM
    maybe one of the morphing plugins would simplify things? https://htmx.org/docs/#morphing
  • b

    boundless-leather-51644

    11/21/2022, 2:22 PM
    Hi
  • b

    boundless-leather-51644

    11/21/2022, 2:23 PM
    Can HTMX handle HTTP return codes which are not 2xx ?
  • m

    mysterious-toddler-20573

    11/21/2022, 2:33 PM
    300-level redirects are handled by the browser before htmx gets access to the request. A
    204 - No Content
    is treated as "nothing to swap". You can modify how other response codes are handled as outlined here: https://htmx.org/docs/#modifying_swapping_behavior_with_events
  • b

    boundless-leather-51644

    11/21/2022, 3:35 PM
    Thanks
  • h

    hundreds-dusk-97323

    11/21/2022, 4:13 PM
    Hi all.. i use fullcalendar and i wanna in eventClick function use htmx open the modal.. this something possible ?
  • b

    boundless-leather-51644

    11/21/2022, 5:18 PM
    What do you suggest to do to implement the following case: A HTML page contains a table which includes different items. An item contains an
    edit
    button. When we click on it we do a GET (= server logic will check if an entity exists). If there is an entity within the DB then we should forward the request to a new screen to edit the entity ?
  • m

    mysterious-toddler-20573

    11/21/2022, 5:34 PM
    this seems like something for client side scripting rather than htmx. htmx should be used to sync with the server, but if something is purely client side, a client side scripting solution will likely be better.
  • m

    mysterious-toddler-20573

    11/21/2022, 5:35 PM
    i would stick w/ a normal CRUD-like interface, where clicking on the button replaces the entire table with an editing UI, and then on save you return to the table (perhaps with the edited element highlighted)
  • m

    mysterious-toddler-20573

    11/21/2022, 5:35 PM
    you could also do an inline editing mechanism, depending on how much there is to show
  • m

    mysterious-toddler-20573

    11/21/2022, 5:36 PM
    relevant examples: https://htmx.org/examples/edit-row/ https://htmx.org/examples/bulk-update/ https://htmx.org/examples/delete-row/
  • b

    boundless-leather-51644

    11/21/2022, 5:39 PM
    Thanks. I will check tomorrow
1...918919920...1146Latest