I'm trying to update an editor template with an Ajax call. The issue is that the returned view has the old data, no matter how I change it.
This is the Ajax call inside the editor template:
@model viewModel
....
$.ajax({
method: 'post',
url: '@Url.Action("GetPrice", "controller")',
data: $('#formId').serialize(),
success: function (result) {
$('#formId').replaceWith(result);
}
});
....
<form id="formId">
<div class="form-group form-inline col-xs-12">
<div class="col-xs-6">
@Html.LabelFor(x => x.field1)
@Html.TextBoxFor(x => x.field1)
</div>
.....
</div>
</form>
The Ajax method:
public ActionResult GetPrice(viewModel row)
{
row.field1++;
return PartialView("~/Views/Shared/EditorTemplates/viewModel.cshtml", row);
}
When I trace the program I can see that it has new values inside the editor template, still the returned data is the old one. I can see that in the Network tab of the developer's tools of my browser.