Hello, I'm attempting to dynamically add controls using a partial view. The controls properly render upon loading the page;however, upon clicking a button which triggers an ajax call to a partial view to render additional controls, the controls return as normal html input controls and are not styled properly.
Would you be able to help me? I've inserted code and screenshot to illustrate what I'm encountering.
View:
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.EJS().DatePicker("datepicker").Placeholder("Date Performed").Render()
@Html.EJS().TimePickerFor(model => model.StartTimeOfWorkout).Width("200px").Placeholder("Start Workout Time").Render()
@Html.EJS().TimePickerFor(model => model.EndTimeOfWorkout).Width("200px").Placeholder("End Workout Time").Render()
<div class="col-md-12">
<button type="button" id="add_drill" class="btn btn-default">Add Drill</button>
</div>
<div class="table-responsive-sm">
<table class="table table-striped" id="drill_workout">
<thead class="drillWorkoutItem">
<tr>
<th scope="col">Drill Name</th>
<th scope="col">Sets</th>
<th scope="col">Reps</th>
<th scope="col">Delete</th>
</tr>
</thead>
@foreach (var drillWorkoutViewModel in Model.DrillWorkoutViewModels)
{
@*@Html.Partial("DrillWorkoutPartial", drillWorkoutViewModel, ViewData)*@
@Html.Partial("DrillWorkoutPartial", drillWorkoutViewModel)
}
</table>
</div>
@Html.HiddenFor(m => m.Id)
@Html.AntiForgeryToken()
<div class="col-md-12">
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<script>
$("#add_drill").on("click", function (e) {
e.preventDefault();
$.ajax({
url: '../Workouts/AddDrillWorkout'
, success: function (partialView) {
// $('#drill_workout> .drillWorkoutItem:last-child').append(partialView);
$("table tbody").append('tr'+ partialView + 'tr');
}
});
});
$("table").on("click", ".delete_it", function () {
$(this).parents("tr").remove();
});
</script>
$("#add_drill").on("click", function (e) {
e.preventDefault();
$.ajax({
url: '../Workouts/AddDrillWorkout'
, success: function (partialView) {
// $('#drill_workout> .drillWorkoutItem:last-child').append(partialView);
$("table tbody").append('
'+ partialView + '
'); }
});
});
$("table").on("click", ".delete_it", function () {
$(this).parents("tr").remove();
});
Partial View:
@{
@using (Html.BeginCollectionItem("DrillWorkoutViewModels"))
{
@Html.EJS().DropDownListFor(model => model.DrillValue).DataSource(@Model.DrillList).Render()

@Html.EJS().TextBoxFor(model => model.Sets).FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Render()
@Html.EJS().TextBoxFor(model => model.Reps).FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Render()
}
}
Screenshot:
https://photos.app.goo.gl/RAWi7FSKDkos4vKt7