Skip to content

How to hx-target="parent"? #2578

Closed Answered by Telroshan
imbolc asked this question in Q&A
May 30, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

In my case widgets often don't have a single root element

This sounds convoluted to me for a "self-contained widget" as you then directly depend on the parent element's styling, for ex a flex row vs a standard block display, could mess up your widget's display.
I would suggest using a root element to enclose your self contained widget as you described in your initial post in this case.

As far as I know, there's no current straightforward selector to achieve exactly what you want (closest * will target the element itself as that's how Element.closest works, by checking the element itself first)
A convoluted way could be using closest :not(#id) (in your example above, for ex <input hx-tar…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@imbolc
Comment options

@Telroshan
Comment options

Answer selected by imbolc
@imbolc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants