gpt4 book ai didi

javascript - 提交表单 javascript 之前确认警报

转载 作者:行者123 更新时间:2023-12-01 08:29:39 27 4
gpt4 key购买 nike

我想从表中删除一行。删除将通过单击 anchor 标记来进行,并将提交删除表单。但在提交表单之前,它会显示一个确认对话框。

<tr>
<td>
<a href="javascript:void(0)" onclick="$(this).parent().find('form').submit().confirm("Are you sure?")">Delete</a>
<form action="{{route('area.destroy',$row->id)}}" method="post">
@method('DELETE')
{{csrf_field()}}
</form>
</td>
</tr>

如何编写 JS/jQuery 代码?另外,如果我想使用 Sweet Alert 我该怎么做?

最佳答案

您可以在 Laravel 中将 SweetAlert 与 AJAX 结合使用

SweetAlert:检查文档:https://github.com/realrashid/sweet-alert

表单 stackoverflow : Delete method with Sweet Alert in Laravel

完整示例:https://youtu.be/bE8Err1twRw

关于javascript - 提交表单 javascript 之前确认警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61915271/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com