我有一个表单,我想在提交时添加一个确认对话框。我使用的this库在大多数情况下运行得很好,但是当我在表单上使用它时,我似乎无法让表单等待响应。我确定它与我如何调用确认功能有关,但我不确定为什么
$('#process_quote').submit(function(){
$.confirm({
text: "Would you like to enter shipping information for this quote?",
confirm: function(button) {
$('input[name=enter_shipping]').val(1);
},
cancelButton: "No",
cancel: function(button) {
$('input[name=enter_shipping]').val(0);
}
});
return true;
});
答案 0 :(得分:1)
将确认信息移至按钮点击处理程序。然后,当您的用户确认时,请提交提交请求。
$('button.trigger').on("click", function(){
$.confirm({
text: "Would you like to enter shipping information for this quote?",
confirm: function(button) {
$('input[name=enter_shipping]').val(1);
$("#process_quote").submit();
},
cancelButton: "No",
cancel: function(button) {
$('input[name=enter_shipping]').val(0);
}
});
});