Jquery 打开模式下的Escape键仅触发一次
我正在处理恼人的错误,我有两个输入的简单引导模式,以及在模式、x或esc上的取消按钮打开的小引导框对话框,问题是,我只能通过esc键打开顶部模式上的引导框对话框一次,引导框对话框关闭,esc键不工作Jquery 打开模式下的Escape键仅触发一次,jquery,modal-dialog,bootbox,Jquery,Modal Dialog,Bootbox,我正在处理恼人的错误,我有两个输入的简单引导模式,以及在模式、x或esc上的取消按钮打开的小引导框对话框,问题是,我只能通过esc键打开顶部模式上的引导框对话框一次,引导框对话框关闭,esc键不工作 <div id="editHoliday" class="fade modal inmodal" tabindex="-1" data- keyboard="false"> <form id="editHoliday_form" class="vm-model-sec"&g
<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>
}
我的目标是,当我在启动对话框上按“取消”时,我能够再次按ESC键并再次打开启动对话框,但只有手动单击某个位置,然后ESC键才能工作
$("#editHoliday").keyup(function (e) {
if (e.which == 27) {
//opens cancel dialog
}
});
有人能解释一下为什么ESC键只工作一次,但为什么我的模式不总是打开的吗?如何解决这个问题?尝试使用:$(document).on('keyup','editHoliday',函数(e){…})代码>-我怀疑bootbox正在进行某种DOM操作,这可能是克隆/销毁等模式。这是(目前)通过设计实现的(请参阅)-假设每次需要显示时都创建一个新的bootbox模式。
$("#editHoliday").keyup(function (e) {
if (e.which == 27) {
//opens cancel dialog
}
});