0
It is possible to pass the filled Model to the controller via jquery, without having to create a variable and populate it with all fields?
Example:
I have a modal popup that opens a partialview with several fields. in this view I have the model:
@model Contato
fields fill the model:
@Html.EditorFor(model => model.Nome)
@Html.EditorFor(model => model.Email)
@Html.EditorFor(model => model.Telefone)
@Html.EditorFor(model => model.Endereco)
@Html.EditorFor(model => model.Documento)
Click on the button to close the model
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal" id="btnSaveContato">
Close
</button>
</div>
Then I want to move the whole model to the controller when I close the popup
<script>
$('#btnSaveContato').on('click', function () {
var model = @model???
});
</script>
without having to do it
var model = {
Nome = campo.val(),
Email = campo.val(),
Telefone = campo.val(),
Endereco = campo.val(),
Documento = campo.val(),
}
It is possible?