Closed flappix closed 12 months ago
I came up with this hacky solution but isn't there a cleaner way?
component
<template x-component="custom-input">
<label>
<span x-html="$prop('label')"></span>
<input type="text" x-on:keydown="change ($event.target.value)" />
</label>
</template>
main html
<body x-data="{foo: 'init value'}">
<vui-custom-input label="label" x-data="{change: function(x) {foo=x;} }"></vui-custom-input>
<span x-html="foo"></span>
</body>
Actually, you could use x-modelable (https://alpinejs.dev/directives/modelable)
A good example is vimesh headless combobox :
https://github.com/vimeshjs/vimesh-headless/blob/master/components/combobox.html
Hi thanks a lot for your fast answer. Works great. I updated the fiddle for future reference: https://jsfiddle.net/78det4qx/
Great framework, really love it.
Hi, is it possible to use x-model in a component and reflecting the changes outside of the component?
I have a component like this
And want to use it in my main html file like
Issue: The variable
foo
is not updating when the value inside the component is changed.https://jsfiddle.net/shtfrjy1/