f-update-url
This commit is contained in:
@@ -26,6 +26,7 @@ import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts";
|
||||
|
||||
export const PARTIAL_ATTR = "f-partial";
|
||||
export const METHOD_ATTR = "f-method";
|
||||
export const UPDATE_URL_ATTR = "f-update-url";
|
||||
|
||||
class NoPartialsError extends Error {}
|
||||
|
||||
@@ -341,9 +342,16 @@ document.addEventListener("submit", async (e) => {
|
||||
};
|
||||
}
|
||||
|
||||
// GET and POST update the URL by default, other methods don't
|
||||
const updateUrl = e.submitter?.getAttribute(UPDATE_URL_ATTR) ??
|
||||
el.getAttribute(UPDATE_URL_ATTR);
|
||||
const shouldNavigate = updateUrl === null
|
||||
? !isCustomMethod
|
||||
: updateUrl !== "false";
|
||||
|
||||
try {
|
||||
await withViewTransition(async () => {
|
||||
await fetchPartials(actionUrl, partialUrl, true, init);
|
||||
await fetchPartials(actionUrl, partialUrl, shouldNavigate, init);
|
||||
});
|
||||
} finally {
|
||||
if (indicator !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user