-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug?] Javascript confirm dialog cancel not working #150
Comments
That way of stopping an event is typical of vanilla JS but the documentation doesn't mention it so I wouldn't expect it to work. The Alpine way for something like that would be:
<form action="/documents/1" method="POST" x-data x-ref="form">
<button x-on:click.prevent="if (confirm('Move to trash?')) $refs.form.submit()" type="submit">Delete</button>
</form> From the documentation: |
Hmm, okay! Thank you for the answer! I think I'll keep the native Leaving this open until @calebporzio has seen it. Feel free to close if not doable, but it would be slick to have in Alpine, no? 😉 How about |
Yeah, I actually think mimicking normal return behavior in an onclick is handy. It kinda goes with the ethos that Alpine should feel very native-eventy. I'd be down for this and I *think it'd be a pretty simple implementation on this line: src/directives/on.js:37 |
I'm re-using this issue to shine light on a discussion I opened today: #2782 It doesn't seem to be working the way it should with regular |
The OG
onclick=""
is working as expected. OK continues the request, and cancel aborts the request.The Alpine version however always continues the request, on both OK and cancel.
Might be me doing something wrong, but I can't seem to get it working. Any ideas?
The text was updated successfully, but these errors were encountered: