Skip to content
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

"TypeError:" in Form Submit Confirmation Controller #1220

Open
Linuxmaker opened this issue Aug 22, 2023 · 1 comment
Open

"TypeError:" in Form Submit Confirmation Controller #1220

Linuxmaker opened this issue Aug 22, 2023 · 1 comment

Comments

@Linuxmaker
Copy link

Hello everyone,

I'm trying to recreate this modal . I don't use a form now, I use a button.
<button type="button" data-controller="submit-confirm" data-action="submit-confirm#onSubmit" class="w-100 btn btn-sm btn-outline-danger" data-bs-trigger="hover" data-bs-toggle="popover" data-bs-placement="top" data-bs-title="Vorsicht! Löschen des Datensatzes!" data-bs-content="Hier wird der Datensatz Betriebshaftpflichtversicherung gelöscht!."><a href="/betriebskosten/entfernen/7">Löschen</a></button>

The corresponding controller "submit_confirm_controller.js looks like this:
`import { Controller } from '@hotwired/stimulus';
import Swal from 'sweetalert2';

export default class extends Controller {
onSubmit(event) {
event.preventDefault();
console.log(event);
Swal.fire({
title: 'Sind Sie sicher?',
text: "Sie können dies nicht rückgängig machen!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ja, löschen Sie es!',
}).then((result) => {
if (result.isConfirmed) {
this.element.submit();
}
})
}
}`

This also works except for deleting the record. Here I get the message in the web browser console:
when I press the submit button of the modal.
Uncaught (in promise) TypeError: _this.element.submit is not a function
Can someone tell me how to fix this error? Or does this solution only work for forms?

Best regards
Andreas

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants