我正在使用 bootbox显示对话框。
如果我使用 bootbox.confirm
, bootbox.alert
或 bootbox.prompt
, 按 escape
时键或单击对话框外部,对话框按预期关闭
但是当使用 bootbox.dialog
,当我在对话框外单击或按 escape
时键,对话框没有关闭,如何让它像其他对话框一样?
var box = bootbox.dialog({
show: false,
backdrop: true,
animate: false,
title: 'Bla',
message: 'bla bla bla',
buttons: {
cancel: {
label: 'Cancel',
className: 'btn-warning'
},
save: {
label: 'Parse',
className: 'btn-success',
callback: function () {
// handling with ajax
return false;
}
}
}
});
box.modal('show');
最佳答案
这应该这样做。请注意,这仅在 v3 上进行了测试。使用 Bootstrap 2.3.2
$(document).on('click', '.modal-backdrop', function (event) {
bootbox.hideAll()
});
关于javascript - 使用自定义对话框时如何关闭引导箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26756500/