assets: add event pageLoaded

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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