Asynchronously adding form validators #2368
-
Hi 👋🏻 Is there a way to asynchronously add form validators? If so, can this be documented? For my use case - I'm consuming components outside of Lit in ERB/Ruby templates. I would like to load all my validators on page load, i.e.:
Is there a way to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @ActuallyACat, did you take a look at: https://lion-web.netlify.app/fundamentals/systems/form/validate/#asynchronous-validation ? |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back to me so quickly! That doesn't quite fit my use case - I'm rendering all my components on the server, and adding my validators once the DOM is loaded. E.g.
It doesn't quite work as I'd expect it to. The I created a similar example in Lit (with the validators added the same way as they're presented in the docs I'm just wondering if there's something I've forgotten to do or am not quite using correctly. Do you have any thoughts? |
Beta Was this translation helpful? Give feedback.
-
Hi @ActuallyACat, Can you make a minimal reproduction on https://stackblitz.com/~/github.com/Knorgias/lion-demo, please? |
Beta Was this translation helpful? Give feedback.
Okay, after reading more of the Lit documentation, it's clear that this approach won't work because all my listeners are being added outside of the Lit lifecycle. I'll need to rejig/rethink my approach to ensure all my event handlers are properly attached. Thanks anyway! :)