simple-svelte-autocomplete
simple-svelte-autocomplete copied to clipboard
valueFieldName doesnt work
Hi :)
<script>
import AutoComplete from "simple-svelte-autocomplete"
let selectedColor;
async function searchColor(keyword) {
return [
{ id:1,color:"White" },
{ id:2,color:"Black" },
]
}
</script>
<AutoComplete
searchFunction={searchColor}
bind:selectedItem={selectedColor}
labelFieldName="color"
valueFieldName="id"
onChange="{() => console.log(selectedColor)}"
/>
selectedColor = { id:1,color:"White" } instead of selectedColor = 1
REPL : https://svelte.dev/repl/b6a3421f9a574c148ba740d88e75ab81?version=4.2.9
Thank you
Yes this is wrong in the readme I think, you should do bind:value={selectedColor} instead.
This example in the read me makes it look like you can use valueFieldName with selectedItem
Thank you @Astronautilus14