我正在处理烦人的错误,我有两个输入的简单引导程序模版,以及小的启动箱对话框,该对话框在模态,x或esc的“取消”按钮上打开,麻烦的是,我只能在顶部模态下打开启动箱对话框通过ESC键一次,启动框对话框关闭,并且ESC键不起作用...
<div id="editHoliday" class="fade modal inmodal" tabindex="-1" data- keyboard="false">
<form id="editHoliday_form" class="vm-model-sec">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="bootbox-close-button close holidayEditCancel" aria-label='Close dialog'><span>×</span></button>
<h1 class="modal-title h4" style="text-align: center;">Edit - Holiday</h1>
</div>
<div class="modal-body">
<div>
<div class="form-group">
<label for="holidayNameEdit" class="vm-holidayname-label">Holiday Name</label>
<input id="holidayNameEdit" name="holidayName" type="text" class="form-control required" maxlength="32">
</div>
</div>
<input id="holidayIdEdit" name="holidayId" type="hidden" />
</div>
<div class="modal-footer">
<button id="holidayEditCancel" type="button" class="btn btn-white holidayEditCancel">Cancel</button>
<button id="holidayEditSave" data-style="expand-right" class="btn btn-primary "><span>Save</span></button>
</div>
</div>
</div>
</form>
在我的.js文件中,启动框对话框
function CancelSaveHoliday() {
bootbox.dialog({
backdrop: true,
closeButton: true,
show: false,
title: "Something",
message: "Would you like to save?,
buttons: {
cancel: {
label: "CANCEL",
className: "",
callback: function () {
}
},
danger: {
label: "NO",
className: "",
callback: function () {
$("#editHoliday").modal("hide");
}
},
main: {
label: "YES",
className: "btn-primary",
callback: function () {
$("#holidayEditSave").click();
}
}
}
}).on("show.bs.modal", function () {
}).on("hidden.bs.modal", function (e) {
renewParentModal($(this), $("#editHoliday_form"), e);
}).modal('show');
}
我的目标是当我在Bootbox对话框中按Cancel时,我能够再次按ESC键并再次打开Bootbox对话框,但是仅当我手动单击某个地方然后ESC键起作用时才有效...
$("#editHoliday").keyup(function (e) {
if (e.which == 27) {
//opens cancel dialog
}
});
有人可以向我解释为什么ESC键只能工作一次,但并不总是为什么打开我的模态吗?我该如何解决?