htmgo/js/extensions/trigger-children.ts
2024-09-12 13:13:15 -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);
});
}
},
});