I have a partial view as popup which, I put an x to click and close the window , but I also want to close the popup as follows: by clicking outside the popup should close.
The code I have is the following: With this I create the popup from the index
<div id="myModal" class="modal fade in">
<div class="modal-content" >
<div class="modal-header" style="background-color: #337ab7;border-color:#2e6da4;color:#fff;">
<button type="button" class="close" data-dissmiss="modal" onclick="cerrarModal();">×</button>
<h5 class="modal-title" >Proveedor</h5>
</div>
<div class="modal-body">
<div id="resultado"></div>
</div>
</div>
javascript
<script>
function cerrarModal() {
$(function () {
$("#myModal").modal("toggle");
});
}
</script>
It does not work for me because something must be wrong. I'm glad about the following error
Apparently I'm using materialize modal when I want to use modal bootstrap.
Layout
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="~/scripts/jquery-3.1.1.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
View index
<head>
<title></title>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="~/Content/materialize.min.css" rel="stylesheet" />
<link href="~/Content/datatables.min.css" rel="stylesheet" />
<link href="~/Content/css/action-btn-wrapper.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />