bootbox确认对话框不要等待

botboox confirm dialog dont wait

我正在使用 bootbox 来确认用户操作。

我有一个提交表单的按钮,单击该按钮后我需要用户确认才能提交或取消:

$(document).ready(function() {
    $(btn_continue).click(function(){

        bootbox.confirm('Are you sure?', function(result){
            if (result) {
                form.submit();
            }
            else {
                return false;
            }
        });

    });
});

问题是弹出窗口出现然后消失,没有等待用户点击! 请问为什么会这样?

尝试删除您的 else 并使用 #btn_continue 中的类型按钮:

$("#btn_continue").click(function(e) {
    bootbox.confirm('Are you sure?', function(result){
      if (result) {
        $("#form").submit();
      }
    });
});

JsFiddle:http://jsfiddle.net/v0h7fer7/

说明: 引导箱正在关闭,因为您正在 post 在它之前编辑您的表格。单击事件处理程序在 bootbox.confirm 的结果之前结束,并允许您的按钮 type="submit" 到 post 您的表单。 bootbox.confirm 是一个 assynchonus 调用。