Is it 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 in 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 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>
I want to pass the whole model to the controller when closing the popup
<script>
$('#btnSaveContato').on('click', function () {
var model = @model???
});
</script>
Without having to do this
var model = {
Nome = campo.val(),
Email = campo.val(),
Telefone = campo.val(),
Endereco = campo.val(),
Documento = campo.val(),
}
Is it possible?