如何隐藏bootbox.js模式

时间:2018-07-30 03:09:49

标签: 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',
            });
          }
        }
      });
    }
  }
});

});

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

2 个答案:

答案 0 :(得分:0)

$('。bootbox.modal')。modal('hide')应该可以帮到您

答案 1 :(得分:-1)

您应该使用下一种方法:

bootbox.hideAll();

文档参考:http://bootboxjs.com/documentation.html#bb-function-hideAll