Row edit: How to handle different hx-target based on success or failure? #1039
Unanswered
SumitBando
asked this question in
Q&A
Replies: 1 comment
-
You can set the target for success condition. But on failure you can change the target server side using the hx-retarget header. https://htmx.org/reference/#response_headers |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a question regarding the common situation of table row edit, e.g. as shown in https://htmx.org/examples/edit-row/
However, I need to update different hx-target based on the result of the edit.
Case 1: if the edit had a validation failure, the target remains the form editing the row
Case 2: if the edit is successful, as a result of data update, e.g. order of rows changes, and the whole table needs to be rendered
I guess I can force a full redirect and redraw on success, or possibly hack something with swap-oob.
Is there a standard pattern to deal with this?
Beta Was this translation helpful? Give feedback.
All reactions