How to update the dom when user redirect to other page via hx-post or hx-get? #1750
Replies: 1 comment
-
Hey, I'm not sure I understand the question, I'm assuming you're talking about a login form, that should redirect your user on a successful authentication, but the redirect seems weird and didn't update the whole page (let me know if that's a misinterpretation there) So first, know that using a standard HTTP redirect will probably be unintuitive at first:
This is actually the expected behaviour, as you might want to redirect partial requests and swap the content of something else than the user asked for in the first place, without redirecting the whole page. Solution: this is where the HX-Redirect header comes in, which instructs htmx to do a full page reload instead. Sending that header on a successful login for example, will bring your user to another whole page |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm a django dev.. I'm facing some problem in htmx redirect.
Just take as an of login page if you are using hx-post for login purpose, how will you update the dom when user redirect to other page? I tried hx-swap='outerHTML' but on redirect page, login form still show. maybe I'm missing something. Anyone who want to share their experience in this?
Beta Was this translation helpful? Give feedback.
All reactions