fix: move test modal to view body, wire button via addEventListener

Razor section forwarding across nested layouts is unreliable.
Modal div and script are now directly in Edit.cshtml body (not in
any section) so they are always in the DOM when the page renders.
Button uses addEventListener instead of inline onclick to decouple
from layout rendering order.

Ref: IT-628

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Anatolii Grynchuk
2026-05-02 03:43:25 +03:00
parent c9f776de80
commit 7587e7fd17
2 changed files with 56 additions and 58 deletions
@@ -123,7 +123,7 @@
</button>
@if (!Model.IsNew)
{
<button type="button" class="btn btn-success" onclick="new bootstrap.Modal(document.getElementById('testModal')).show()">
<button type="button" class="btn btn-success" id="testModalBtn">
<i class="bi bi-send me-1"></i> Test
</button>
}
@@ -135,7 +135,6 @@
@if (!Model.IsNew)
{
@section Scripts {
<div class="modal fade" id="testModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
@@ -159,6 +158,10 @@
</div>
<script>
document.getElementById('testModalBtn').addEventListener('click', function () {
bootstrap.Modal.getOrCreateInstance(document.getElementById('testModal')).show();
});
async function sendTestEmail(channelId) {
const toEmail = document.getElementById('testToEmail').value.trim();
const resultDiv = document.getElementById('testResult');
@@ -194,5 +197,4 @@
}
}
</script>
}
}
@@ -14,7 +14,3 @@
</div>
</div>
</div>
@section Scripts {
@RenderSection("Scripts", required: false)
}