autosave:before:request#
Hook emitted before the autosave transport request is built. Handlers may return a modified payload (url, init).
Type: hook (handler may return a value).
Payload:
Example:
app.on('autosave:before:request', ({ name, data, url, method, init }) => {
return {
url,
init: { ...init, credentials: 'include' }
};
});
autosave:before:send#
Hook emitted before autosave sends content (HTTP request or custom handler). Call stop() in the handler to cancel the save.
Type: hook (handler may return a value; call stop() to cancel).
Payload:
- name — string — form field name for HTML content
- data — request body object
- url — string — request URL
- method — string — HTTP method
- stop — function — call to cancel the operation
Example:
app.on('autosave:before:send', ({ data, stop }) => {
if (document.body.dataset.readonly === '1') {
stop();
return;
}
return { data: { ...data, saved_at: Date.now() } };
});
autosave:error#
Emitted when autosave fails.
Type: signal.
Payload:
Example:
app.on('autosave:error', ({ name, error, response }) => {
toast.show(`Save failed: ${error?.message || response?.message}`);
});
autosave:send#
Emitted when autosave sends content to the server.
Type: signal.
Payload:
Example:
app.on('autosave:send', ({ name, data, response }) => {
markDocumentSaved(data[name], response);
});