rsan
rsan

Reputation: 1887

Is there an HTMX trigger event that waits until custom elements are defined?

I am using shoelace component library that uses custom elements. I want to trigger an htmx AJAX request when the custom element is defined. Tried using load event and it works correctly when the custom elements were defined previously but if I refresh the page, then load event is triggered before the component is fully loaded failing to send the value of the element. Is there an event in htmx that could be helpful for this use case? If not, how could I register a custom event that is triggered when the element is loaded and defined.

<sl-select name="my_name" value="my_value"
  hx-get="/url"
  hx-include="[name='my_name']"
  hx-trigger="load" //This triggers before component is defined, then my_value is not sent. 
>
  ...
</sl-select>

Upvotes: 0

Views: 139

Answers (0)

Related Questions