Add new event htmx:beforeHistoryUpdate (#1573)

* Add missing documentation for htmx:replacedInHistory

* Add new event htmx:beforeHistoryUpdate
This commit is contained in:
Sascha Woo 2023-10-07 06:22:44 +02:00 committed by GitHub
parent 332e8986ac
commit 4f63581c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -3535,6 +3535,7 @@ return (function () {
// if we need to save history, do so
if (historyUpdate.type) {
triggerEvent(getDocument().body, 'htmx:beforeHistoryUpdate', mergeObjects({ history: historyUpdate }, responseInfo));
if (historyUpdate.type === "push") {
pushUrlIntoHistory(historyUpdate.path);
triggerEvent(getDocument().body, 'htmx:pushedIntoHistory', {path: historyUpdate.path});

View File

@ -344,6 +344,19 @@ attribute. If this event is cancelled, the AJAX request will not occur.
* `detail.target` - the target of the request
* `detail.prompt` - the user response to the prompt
### Event - `htmx:beforeHistoryUpdate` {#htmx:beforeHistoryUpdate}
This event is triggered before a history update is performed. It can be
used to modify the `path` or `type` used to update the history.
##### Details
* `detail.history` - the `path` and `type` (push, replace) for the history update
* `detail.elt` - the element that dispatched the request
* `detail.xhr` - the `XMLHttpRequest`
* `detail.target` - the target of the request
* `detail.requestConfig` - the configuration of the AJAX request
### Event - `htmx:pushedIntoHistory` {#htmx:pushedIntoHistory}
This event is triggered after a URL has been pushed into history.
@ -352,6 +365,14 @@ This event is triggered after a URL has been pushed into history.
* `detail.path` - the path and query of the URL that has been pushed into history
### Event - `htmx:replacedInHistory` {#htmx:replacedInHistory}
This event is triggered after a URL has been replaced in history.
##### Details
* `detail.path` - the path and query of the URL that has been replaced in history
### Event - `htmx:responseError` {#htmx:responseError}
This event is triggered when an HTTP error response occurs