I’m trying to implement the following idea:
When you save a User is a matter without a cover
is to ask whether to save anyway by sending a question to him with jquery.
but the problem is that no matter if he chooses the option that it saves the same way
I’m using this jquery .. some form to make such a request .. when to cancel
he did not do anything on a page or not restrain oo [HttpPost] of mvc?
this and I’m using jquery
<script type="text/javascript">
$(document).ready(function () {
$("#Salvar").click(function () {
if ($("#CapaSelecionada").val() == null) {
var answer = confirm("Deseja criar uma materia sem capa?")
if (answer) {
alert("salvou");
} else {
location.pathname;
}
}
});
});
</script>
To cancel the post you’ve got two options:
return false;from the ‘no’ caseaccept the event arg on your function and call
event.preventDefault():return false;is stronger theevent.preventDefault()and some people prefer the latter to allow you to hook more events onto your buttons, but chances are in your situtatonreturn falsewill do just as well.