close modal when clicking outside area

This commit is contained in:
YutaMatsushima 2019-07-04 16:18:48 +09:00 committed by Shinsuke Sugaya
parent a2eef21f94
commit aed6b2bb47
2 changed files with 8 additions and 5 deletions

View file

@ -10,6 +10,12 @@ $(function() {
return true;
});
$(document).on("click touchend", function(e) {
if (!$(e.target).closest("#searchOptions, #searchOptionsButton").length) {
$("#searchOptions").removeClass("active");
}
});
$("[data-toggle='control-options']").click(function(e) {
e.preventDefault();
var target = $(this).attr("data-target") || $(this).attr("href");

View file

@ -14,11 +14,8 @@ $(function() {
return true;
});
$("#content").on("click touchend", function(e) {
if (
!$(e.target).closest("#searchOptions, [data-toggle='control-options']")
.length
) {
$(document).on("click touchend", function(e) {
if (!$(e.target).closest("#searchOptions, #searchOptionsButton").length) {
$("#searchOptions").removeClass("active");
}
});