✅ Nested views failing

Hello! so, I've got a small issue.
I have this view called Edit which has the following button:

<div class="form-group">
<input type="submit" id="SaveEdit" value="Save" class="btn btn-primary" />
</div>

I am trying to get it so that when this button is clicked, it takes the user back to having the details view opened in this part of the dashboard view (note the page with the submit button is currently opened in there)

<div class="dash-content col py-3" id="contentArea">

</div>


this is my current js

$('#SaveEdit').click(function() {
preventDefault(); // Prevent the default action of the link
var submissionId = $(this).attr('value'); // Get the ID of the submission
$.ajax({
url: '/Submission/Edit/' + submissionId,
type: 'GET',
success: function(result) {
$('#contentArea').html(result);
}
});
});


here's the end point it hits:

[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int id, Event @event)
{
if (id != @event.EventId)
{
return NotFound();
}
ModelState.Remove("");
if (ModelState.IsValid)
{
try
{
var @submission = await _context.Event.FirstOrDefaultAsync(m => m.EventId == id);
@submission.EventEditedDate = @event.EventEditedDate;
_context.Update(@submission);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!EventExists(@event.EventId))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction("Details", new { id = id });
}
return RedirectToAction("Details", new { id = id });
}


and this is the Details end point:

[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int? id)
{
if (id == null || _context.Event == null)
{
return NotFound();
}
var @event = await _context.Event.FindAsync(id);
if (@event == null)
{
return NotFound();
}
return View(@event);
}


I have some almost identical code that works fine, but this one seems to just open the view as a whole view instead of nested inside the first
Was this page helpful?