You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to prevent navigating away from a page under certain condition, such as when the page contains a form with unsaved changes?
(Something like beforeNavigate in SvelteKit)
The text was updated successfully, but these errors were encountered:
Set a flag in context which indicates there are changes isDirty, then do something like this:
let ctx = getContext("unsavedChanges");
window.onload = function() {
window.addEventListener("beforeunload", function (e) {
if (!ictx.isDirty) {
return undefined;
}
< do js to show the message >
});
};
We could store this state inside the route config but you'd need to pass that into the config.
Is there a way to prevent navigating away from a page under certain condition, such as when the page contains a form with unsaved changes?
(Something like beforeNavigate in SvelteKit)
The text was updated successfully, but these errors were encountered: