-
I'm trying to develope a simple form validator by defining a FormElmBase.svelte file that commonly hooks the input onchange event with an external
and then define a TextInput.svelte as below (so does textarea):
and Dropdown.svelte as below:
I'm now at my wits end |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I had thought of using bindable rune, https://svelte.dev/docs/svelte/$bindable However, the children snippet of the FormElmBase is unknown beforehand |
Beta Was this translation helpful? Give feedback.
-
You cannot use a regular binding unless you have a property, you probably could use the function binding syntax, though. Using a property the rendering should be done as: {@render children?.({ set this(el) { inputElement = el } })} You can only make use of this argument by explicitly defining the snippet, it would look like this: <FormElmBase>
{#snippet children(context)}
<input bind:this={context.this} />
{/snippet}
</FormElmBase> |
Beta Was this translation helpful? Give feedback.
You cannot use a regular binding unless you have a property, you probably could use the function binding syntax, though. Using a property the rendering should be done as:
You can only make use of this argument by explicitly defining the snippet, it would look like this:
Playground