javascript - 如何隐藏 bootbox.js 模态

标签 javascript jquery bootbox

我想隐藏我所有的 bootbox模态。我目前有 2 个模态框,在单击“取消”后,我想隐藏所有其他模态框。

这是我的代码:

$('#table-grid').delegate(".requestBill", "click", function () { // store the checked checkbox ticket_id into array 
const prop_id = $(this).data('prop_id');
bootbox.prompt({
  title: "Request Bill",
  inputType: 'textarea',
  placeholder: 'Enter Additional Message',
  value: 'I am requesting an RPT Bill.',
  buttons: {
    confirm: {
      label: 'Submit'
    },
    cancel: {
      label: 'Cancel',


    }
  },
  callback: function (result) {
    if (result == null) {
      $.toast({
              heading: 'Note',
              text: 'Cannot request bill without describing reason(s)',
              icon: 'error',
              loader: false,
              stack: false,
              position: 'top-center',
              allowToastClose: false,
              bgColor: '#f0ad4e',
              textColor: 'white',
            });
    } else if (result == "") {
      $.toast({
              heading: 'Note',
              text: 'Cannot request bill without describing reason(s)',
              icon: 'error',
              loader: false,
              stack: false,
              position: 'top-center',
              allowToastClose: false,
              bgColor: '#f0ad4e',
              textColor: 'white',
            });


    } else {
      var fd = new FormData();
      fd.append("prop_id", prop_id);
      fd.append("content", result);
      $.ajax({
        type: "POST",
        url: base_url + "Main_declaration/request_bill",
        data: fd,
        contentType: false,
        cache: false,
        processData: false,
        beforeSend: function () {
          $(".requestBill").attr('disabled', true)
        },
        success: function (data) {
          if (data.success == 1) {
            $.toast({
              heading: 'Success',
              text: data.message,
              icon: 'success',
              loader: true,
              stack: false,
              position: 'top-center',
              allowToastClose: false,
              bgColor: '#5cb85c',
              textColor: 'white',
            });
          } else {
            $.toast({
              heading: 'Note',
              text: data.message,
              icon: 'error',
              loader: false,
              stack: false,
              position: 'top-center',
              allowToastClose: false,
              bgColor: '#f0ad4e',
              textColor: 'white',
            });
          }
        }
      });
    }
  }
});

});

隐藏引导框模态(所有模态)的语法是什么?

最佳答案

你应该使用下一个方法:

bootbox.hideAll();

文档引用:http://bootboxjs.com/documentation.html#bb-function-hideAll

关于javascript - 如何隐藏 bootbox.js 模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51586506/

相关文章:

javascript - 通过 ID 获取元素不起作用

javascript - 如何在onclick函数中获取Var?

javascript regExp检查最后一个字符

javascript - 你能 "accumulate" promise 导致 "then"链吗?

jquery - 既然 MS 正在备份 JQuery,我应该继续使用 Mootools 吗?

javascript - Bootbox 中的多个输入

javascript - 使用类而不是 ID 发布 ajax 数据

javascript - 在ajax响应中加载列表对象并使用此数据创建动态列表div

twitter-bootstrap - Bootstrap 和 Bootstrap 箱 : dynamically change the width of confirmation window