UNPKG

611 BJavaScriptView Raw
1htmx.defineExtension('restored', {
2 onEvent : function(name, evt) {
3 if (name === 'htmx:restored'){
4 var restoredElts = evt.detail.document.querySelectorAll(
5 "[hx-trigger='restored'],[data-hx-trigger='restored']"
6 );
7 // need a better way to do this, would prefer to just trigger from evt.detail.elt
8 var foundElt = Array.from(restoredElts).find(
9 (x) => (x.outerHTML === evt.detail.elt.outerHTML)
10 );
11 var restoredEvent = evt.detail.triggerEvent(foundElt, 'restored');
12 }
13 return;
14 }
15})
\No newline at end of file