htmgo/js/extensions/triggerchildren.ts
2024-09-12 12:15:17 -05:00

13 lines
371 B
TypeScript

import * as htmx from "htmx.org";
import { HtmxEvent } from "htmx.org";
htmx.defineExtension("trigger-children", {
onEvent: (name: HtmxEvent, evt: CustomEvent) => {
const target = evt.detail.target as HTMLElement;
if (target && target.children) {
Array.from(target.children).forEach((e) => {
htmx.trigger(e, name, null);
});
}
},
});