Problem: I'm in the view index, it has a button that opens the Create view on a modal screen, on that modal screen I want to execute a javascript code, but for some reason it is not running.
I'm opening a modal view with the following code:
$("#btnNovo").click(function () {
$(".modal-body").load("/Pais/Create", function () {
$("#exampleModal").modal("show");
});
});
View open in modal.
@model Projeto.WebERP.EntityFramework.Entities.Pais
@{
ViewBag.Title = "Create";
Layout = null;
}
<h2> Cadastro de País </h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Handle)
<hr />
<div class="form-horizontal">
<div class="row">
<!-- DESCRICAO -->
<div class="col-md-4">
<label for="txtDescricao"> Descrição: </label>
@Html.TextBoxFor(model => model.Descricao, new { type = "text", @class = "form-control", id = "txtDescricao" })
@Html.ValidationMessageFor(model => model.Descricao, "", new { @class = "text-danger" })
</div>
<!-- SIGLA -->
<div class="col-md-2">
<label for="txtSigla"> Sigla: </label>
@Html.TextBoxFor(model => model.Sigla, new { type = "text", @class = "form-control", id = "txtSigla" })
@Html.ValidationMessageFor(model => model.Sigla, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="row">
<!-- DATACADASTRO -->
<div class="col-md-4">
<label for="txtDataCadastro"> Data Cadastro: </label>
@Html.TextBoxFor(model => model.DataCadastro, new { type = "datetime", @class = "form-control", readOnly = true, id = "txtDataCadastro" })
@Html.ValidationMessageFor(model => model.DataCadastro, "", new { @class = "text-danger" })
</div>
<!-- DATAALTERACAo -->
<div class="col-md-4">
<label for="txtDataAlteracao"> Data Alteração: </label>
@Html.TextBoxFor(model => model.DataAlteracao, new { type = "datetime", @class = "form-control", readOnly = true, id = "txtDataAlteracao" })
@Html.ValidationMessageFor(model => model.DataAlteracao, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="row">
<div class="col-md-2">
<input type="submit" id="sumitForm" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
@section Scripts{
<script>
$(document).ready(function () {
alert("dsdsd");
});
</script>
}