Fixes view script loading and request handling on the web frontend

Executes the view scripts after the application scripts have loaded, both on
the initial page load and during AJAX navigation, instead of running them
during HTML parsing when the API helpers are not defined yet. Sends an empty
JSON object for requests without a payload, because FastEndpoints parses the
JSON body when the content type is application/json. Adds the antiforgery
token to the management views that issue protected write requests.
This commit is contained in:
BinaryAlley committed 2026-08-26 19:16:21 +03:00
1 parent ccefb65c83
commit ba9a49b0db
14 files changed
+109 -70

No files matched your search

@@ -145,7 +145,8 @@
</div>
@section Scripts {
<script type="text/javascript" data-form="@scriptId" defer>
<!-- The "text/plain" type is a design choice, not a mistake: it keeps the browser from executing this view script during HTML parsing, before site.js defines the API helpers it calls (callApiGetAsync, callApiPostAsync, ...). site.js (which loads deferred) executes these scripts once it is loaded, both on the initial page load and during AJAX navigation. -->
<script type="text/plain" data-form="@scriptId">
// create cleanup registry for this view
const cleanupFunctions = [];
let isInitialized = false;