Sunday 3 January 2021

Disable buttons and show hourglass over row (htmx)

I use htmx to updated snippets of my page via html-over-the-wire

This works fine:

  <table>
    <tr id="offer_2">
     <td>Sun 27.12</td>
     <td>Spinach Lasagna</td>
     <td>5.00€</td>
     <td>1</td>
     <td>
      <button id="2" hx-post="/offer/2/add_offer_to_order" 
         hx-target="#offer_2" hx-swap="outerHTML">+</button>
      <button id="2" hx-post="/offer/2/delete_offer_from_order" 
         hx-target="#offer_2" hx-swap="outerHTML">-</button>
     </td> 
    </tr> 
   </table>

.... after the user pushed the + or the - button, the corresponding row gets updated with a new version from the server.

I would like to give the user some visual feedback:

  • the buttons should be disabled during the ajax-call
  • there should be a hourglass turning above the row which gets updated.


from Disable buttons and show hourglass over row (htmx)

No comments:

Post a Comment