我正在使用这个插件 - https://craftpip.github.io/jquery-confirm/ 在提交表格之前进行确认。 这是我的 HTML:
<form action="" method="post">
<input type="hidden" name="comment_id" value="">
<button name="delete" class="btn btn-danger btn-xs confirm_delete"><span class="glyphicon glyphicon-remove"></span> Delete</button>
</form>
还有我的javascript:
$("button.confirm_delete").confirm({
title: '',
content: 'Please confirm you want to delete this item. This action is irreversible!',
buttons: {
confirm: function () {
this.$target.submit();
},
cancel: function () {
}
}
});
确认后,什么也没有发生。在控制台中,我在这一行得到了[button.btn.btn-danger.btn-xs.confirm_delete]:this.$target.submit(); 我是什么做错了吗?
最佳答案
您需要在确认点击中使用它
this.$target.parent().submit()
this
是确认对象
$target
作为你的删除按钮
和
parent()
成为你的形式
这是给你的 fiddle https://jsfiddle.net/fxabnk4o/5/
请注意,如果您按照显示的方式设置了 HTML,这将起作用
关于jquery-confirm 插件 - 提交表单确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44932568/