Close modal with bg click or escape key

master
Dessa Simpson 2020-07-05 20:41:42 -07:00
parent 603769d5fd
commit e54db3c4eb
2 changed files with 7 additions and 1 deletions

View File

@ -43,3 +43,9 @@ function closeAddRequestModal() {
} }
updateTable(); updateTable();
document.addEventListener("keydown", function onEvent(event) {
if (event.key === "Escape") {
closeAddRequestModal();
}
});

View File

@ -30,7 +30,7 @@
</select> </select>
<input type="checkbox" id="allRequests" onchange="updateTable()">View requests in any state</input> <input type="checkbox" id="allRequests" onchange="updateTable()">View requests in any state</input>
</div> </div>
<div id="addRequestModalBackground"> <div id="addRequestModalBackground" onclick="closeAddRequestModal()">
<div id="addRequestModal"> <div id="addRequestModal">
<div id="addRequestModalClose"><a href="#" onclick="closeAddRequestModal()">&times;</a></div> <div id="addRequestModalClose"><a href="#" onclick="closeAddRequestModal()">&times;</a></div>
<h1>Add Request</h1> <h1>Add Request</h1>