0
I created a modal block to display my View Create. When you click on btnNovo, a javascript event should call my Action Create to return a blank view and click inside the modal... Only the modal is opening. I followed with BP and found that the click event is not calling the Action Create with the route I am passing. Can anyone tell me where I’m going wrong?
[HttpGet]
[Authorize(Policy = "CanWritePessoaSituacaoData")]
[Route("situacoes-gerenciamento/cadastrar-novo")]
public IActionResult Create()
{
return View();
}
Below is the btnNovo code, the modal block and the ref. to the script:
<a id="btnNovo" class="btn btn-outline btn-default new" data-toggle="modal" href="#myModal"
data-original-title="Cadastrar Novo" >
<span title="Cadastrar Novo" class="icon wb-plus"></span> Cadastrar Novo
</a>
<div id="myModal" class="modal fade" role="dialog" data-backdrop="static" tabindex='-1' aria-labelledby="myModalLabel" aria-hidden="true" style="display:none" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title" id="myModalLabel">Gerenciar Situações de Pessoas</h4>
</div>
<div class="modal-body">
<div id="modal-content">
Carregando...
</div>
</div>
</div>
</div>
</div>
@section scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script src="~/js/PessoaSituacao/PessoaSituacao.js"></script>
<script type="text/javascript">
}
Follow the js script:
$("btnNovo").click(function (eve) {
$("#modal-content").load("situacoes-gerenciamento/cadastrar-novo");
});
What is the controller name and route for it? the path in the load is incomplete
$("#modal-content").load("/{controller}/situacoes-gerenciamento/cadastrar-novo");
– Leandro Angelo
Personal Controller Action Create.
– Master JR
Did you try?
$("#modal-content").load("/PesssoaSituacao/situacoes-gerenciamento/cadastrar-novo");
?– Leandro Angelo
I had tried, but I think I was wrong to pass a wrong route... Now yes, it worked!!! Thanks Leandro!
– Master JR