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

    lively-vegetable-81321

    05/15/2023, 8:17 PM
    And I'm guessing it's the same for
    hx-post
    , yes?
  • g

    great-cartoon-12331

    05/15/2023, 8:32 PM
    i haven'tr tried it, you can check pretty easily in your Network tab though to see the actual request that gets sent
  • h

    hundreds-jordan-64279

    05/15/2023, 10:23 PM
    Do you think part of the success of htmx is the excellent naming? Ie sounds like the next evolution of html
  • h

    hundreds-stone-62176

    05/15/2023, 11:07 PM
    Someone is testing a bot here, I think.
  • h

    hundreds-jordan-64279

    05/16/2023, 10:17 AM
    lol thanks for the ... compliment?
  • l

    lively-vegetable-81321

    05/16/2023, 5:47 PM
    Hello. I'm having trouble deleting a row from a table. I'm following the example here: https://htmx.org/examples/delete-row/ and I've got my markup looking pretty much identical but it does not work. I get the pop-up opening to confirm the deletion, I see the network call being made and the deletion is happening on the backend, but the row is not removed from the UI. One possible cause is that the backend is returning a 204 No Content. Could that be the reason the row is not being removed?
  • g

    gorgeous-ghost-95789

    05/16/2023, 5:49 PM
    There's a lot of moving parts, so it's hard to say for certain, but yes - htmx usually ignores a 204 No Content. Depending on the size of your table, I've found it's often best to just re-render and replace the whole table.
  • l

    lively-vegetable-81321

    05/16/2023, 5:50 PM
    I can quickly try returning a 200 with an empty body to see if it fixes it.
  • l

    lively-vegetable-81321

    05/16/2023, 5:50 PM
    Thanks @gorgeous-ghost-95789 .
  • g

    gorgeous-ghost-95789

    05/16/2023, 5:55 PM
    Yeah, that's an easy thing to experiment with. Some browsers lose their minds when you try to yank a straight out of a table. If you run into trouble, check out https://htmx.org/docs/#config and try the setting named
    htmx.config.useTemplateFragments
    -- this uses a more modern way of handling swaps, which is often more resillient. Or, look at the idiomorph extension (https://github.com/bigskysoftware/idiomorph)
  • s

    shy-zebra-22292

    05/16/2023, 5:56 PM
    Can't wait to see rule 34 on this Discord Server... 😛
  • l

    lively-vegetable-81321

    05/16/2023, 5:56 PM
    Yes, that fixes it. Too bad because I like to return 204 in such cases. Could this be considered a bug?
  • r

    ripe-action-67367

    05/16/2023, 5:59 PM
    It's working as intended https://htmx.org/docs/#requests
  • l

    lively-vegetable-81321

    05/16/2023, 6:02 PM
    I see. Thanks @ripe-action-67367
  • h

    high-microphone-71328

    05/16/2023, 6:34 PM
    Question: I have a button that makes a request that needs some user input. 1. how do I access the value from hx-prompt? 2. is there a way to save that value from the first hx-prompt so that next time the hx-prompt won't fire
  • l

    limited-teacher-83117

    05/16/2023, 7:24 PM
    More details on what you're trying to accomplish would be helpful because this is a classic case where you might just be coming at the problem from the client-side framework perspective 1. Have you considered using a form? i.e. the button submits a form with the input filled out. Probably a better UX in most cases 2. If you need to use the prompt, what do you mean by "access"? Roughly speaking, the idiom is to send user input to the server, and then have the server return some HTML that reflects whatever the user provided i.e. The user enters a name into the prompt, the HTML that is returned by the server includes that name somewhere I can be more specific if that doesn't help
  • h

    high-microphone-71328

    05/16/2023, 7:28 PM
    You are correct, I am definitely trying to do it on the client side. I will try the form option tho. I'll probably mix in some alpinejs as well
  • l

    limited-teacher-83117

    05/16/2023, 7:29 PM
    There are often cases where it's smart to do stuff on the client! Everyone's got a slightly different idea of where that line is drawn.
  • l

    limited-teacher-83117

    05/16/2023, 7:30 PM
    If you want to access it so you can update a different part of the page, try
    hx-swap-oob
    . If you want it to populate a later request, try returning a pre-populated
    input
    . Just some other options to consider
  • h

    high-microphone-71328

    05/16/2023, 8:06 PM
    btw this might be my answer: https://htmx.org/attributes/hx-trigger/#:~:text=Conditions%20can%20also%20refer%20to%20global%20functions%20or%20state
  • f

    famous-monitor-57000

    05/16/2023, 9:07 PM
    Hello, I'm trying to get a request to override a polling request (if both are made at the same time). I've posted the question here: https://stackoverflow.com/questions/76267037/how-to-make-a-request-override-a-polling-request
  • f

    famous-monitor-57000

    05/16/2023, 9:08 PM
    Basically, I have a table on a page that that automatically updates every second, like this:
    Copy code
    <div class="table" hx-post="/table.php" hx-trigger="load, every 1s"></div>
    I also have a button that can move to a specific position in the table, like this:
    Copy code
    <button hx-post="/table.php" hx-target=".test" hx-vals='{"position": "100"}'>100</button>
    How do I make the button always override any polling request that is being made at the time? For example, if I click the button while the
    every 1s
    polling request is being processed.
  • r

    ripe-action-67367

    05/16/2023, 10:00 PM
    https://htmx.org/docs/#synchronization
  • r

    ripe-action-67367

    05/16/2023, 10:04 PM
    Also see this for syntax of the selector in hx-sync https://htmx.org/docs/#extended-css-selectors
  • f

    famous-monitor-57000

    05/16/2023, 11:04 PM
    Thanks. Would this be the right solution?
    Copy code
    <div class="table" hx-post="/table.php" hx-trigger="load, every 1s" hx-sync=".table:abort"></div>
    
    <button hx-post="/table.php" hx-target=".table" hx-vals='{"position": "100"}'>100</button>
  • f

    famous-monitor-57000

    05/16/2023, 11:08 PM
    Hmm still doesn't seem to be working as I hoped. Is
    hx-sync=".table:abort"
    the right syncing strategy?
  • m

    mysterious-toddler-20573

    05/16/2023, 11:16 PM
    put
    hx-sync=".table"
    on the button
  • m

    mysterious-toddler-20573

    05/16/2023, 11:16 PM
    so they are using the same element to sync on
  • f

    famous-monitor-57000

    05/16/2023, 11:24 PM
    Thank you. I've tried that but I still seem to be having the same problem.
  • select tag
    n

    narrow-quill-86201

    05/16/2023, 11:30 PM
    I would like to change the value like shown in the code selectElement('leaveCode', '14') In this example I have a select list Annual Leave Medical Leave Long Service Leave Without Pay and I can set the value in javascript function selectElement(id, valueToSelect) { let element = document.getElementById(id); element.value = valueToSelect; } selectElement('leaveCode', '14'); I want to use htmx to set the option with a htmx-get Get & Set on server fastify.get('/get-select', { }, async (req, reply) => { defmenu='17' return reply.send(defmenu); }) I've tried using different hx-swap methods but it all fails
    l
    • 2
    • 3
1...113011311132...1146Latest