Initialize custom form component

I have a custom component that has a script for initializing the field, setting up the DOM for the field. I want this field to be hidden by default, but I noticed it's not present in the DOM before it becomes visible. Is there a way to either call the javascript function when it becomes visible, or have the field be present in the DOM?
3 Replies
Dennis Koch
Dennis Koch2y ago
Probably via Alpine x-data x-init="your JS"
Oliverdam
OliverdamOP2y ago
Thanks. I'll give it a shot
Oliverdam
OliverdamOP2y ago
Thanks again, that's exactly what I was looking for.

Did you find this page helpful?