I have a form that has a partial view (can be append multiple times) on button click with jQuery.
$("#addPerson").on('click', function () {
$.ajax({
type: "POST",
url: '@Url.Action("Partial_View")',
success: function (res) {
$("#personForm").append(res);
},
error: function (err) { console.log('err: ' + err)
});
});
I want the parent page to post each partial view's form data on a single submit button.
What is the best way to set up the parent/partial viewmodels and achieve this?
Let's say the repeated partial view has this model for now:
public class PartialViewModel {
public Person Person {get; set;}
public int PersonCount {get; set;}
}
public class Person {
public string FirstName {get; set;}
public string LastName {get; set;}
}