assets: add event pageLoaded

This commit is contained in:
2024-06-03 10:02:42 +02:00
parent df9e3a9f61
commit 185fb57fd6
5 changed files with 35 additions and 29 deletions

View File

@ -136,6 +136,11 @@ export default class PageLoad {
history.pushState(state, '', url)
}
dispatchPageLoaded(url) {
var evt = new CustomEvent("pageLoaded", {detail: url})
document.dispatchEvent(evt)
}
// --- events
pageChanged(event) {
let submit = event.type == 'submit';
@ -161,7 +166,7 @@ export default class PageLoad {
else
options = {...options, method: target.method, body: formData}
}
this.load(url, options).then(() => this.historySave(url))
this.load(url, options).then(() => this.dispatchPageLoaded(url)).then(() => this.historySave(url))
event.preventDefault();
event.stopPropagation();
}