Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valueFieldName doesnt work #217

Open
gponty opened this issue Jan 26, 2024 · 2 comments
Open

valueFieldName doesnt work #217

gponty opened this issue Jan 26, 2024 · 2 comments

Comments

@gponty
Copy link

gponty commented Jan 26, 2024

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

@gponty gponty changed the title valueField doesnt work valueFieldName doesnt work Jan 26, 2024
@Astronautilus14
Copy link

Astronautilus14 commented Feb 5, 2024

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

@gponty
Copy link
Author

gponty commented Feb 6, 2024

Thank you @Astronautilus14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants