Skip to content

Commit 2f57897

Browse files
committed
use hx_swap delete
1 parent 51e19da commit 2f57897

File tree

1 file changed

+2
-5
lines changed
  • examples/dynamic_user_interface_(htmx)/delete_row

1 file changed

+2
-5
lines changed

examples/dynamic_user_interface_(htmx)/delete_row/app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def __ft__(self):
2323
hx_confirm="Are you sure?",
2424
# Target the closest row (The one you clicked on)
2525
hx_target="closest tr",
26-
# Swap out the row with nothing (removes the row)
27-
hx_swap="outerHTML")))
26+
# Removes the row with htmx
27+
hx_swap="delete")))
2828

2929
# Sample data
3030
# Often this would come from a database
@@ -43,11 +43,8 @@ def index(sess):
4343
# A `Contact` object is rendered as a row automatically using the `__ft__` method
4444
Tbody(*(Contact(**x) for x in sess['contacts'])))
4545

46-
4746
@app.delete
4847
def delete(id: int, sess):
4948
sess['contacts'] = [c for c in sess['contacts'] if c['id'] != id]
50-
# Return nothing to the HTMX request to swap in nothing (removes the row)
51-
5249

5350
serve()

0 commit comments

Comments
 (0)