Giter Club home page Giter Club logo

Comments (3)

imacrayon avatar imacrayon commented on July 24, 2024

Hey Mike, thanks for reaching out.

If you're using v0.7 you can add a second x-target to your form like this: x-target.3xx="_self". That will ensure the page still redirects when any 3xx status code is returned from the server.

If you're using any version less than v0.7 adding the nofollow modifier to x-target was the old way to do this: x-target.nofollow="login_form_id".

from alpine-ajax.

MikeHarrison avatar MikeHarrison commented on July 24, 2024

Hi,
Thanks for the reply, sorry it has taken so long to respond.

My form tag now looks like this:

<form x-init x-target x-target.3xx="_self" id="login-form" action="<?php echo $page->url() ?>" method="POST">

When I put in the correct credentials to log in, I am getting redirected as I would like. Which is great. But I am now not getting any of my error messages when login fails (e.g. if the wrong password is entered).

I may well be doing something wrong, or need to update my form handler in some way. If you have any insight or thoughts that would be great.

from alpine-ajax.

imacrayon avatar imacrayon commented on July 24, 2024

Ok, sounds like you're on the right track. So since you're using a naked x-target only the the form element (#login-form) will be changed when you submit the form. If the error messages live outside the <form> that could explain why they're not showing.

If that's that case, you could either target a different element that contains both your errors and the form, or you can specify multiple IDs in x-target like this x-target="login-form form-errors".

If that's not the case, I might need some more context, maybe what the page markup is like or how you're handling the form response server side.

from alpine-ajax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.