-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Expand "bind:value <select>" tutorial with pre-selected option #7430
Comments
What do you mean by "pre-select an option"? |
If I bind the select to |
It took about 30 seconds to find out in REPL (the answer is yes, that's how the two way binding works. In both directions.) https://svelte.dev/repl/a58cf1653f494b10b04abcda4a139844?version=3.46.6 The tutorial binds to the object as value, so you can do |
I added a sentence to the "note" box from which it should be clear that you can do this. And as @Prinzhorn says, this is something that you can find out in no time. We need to find a good balance of what to put into the tutorial. If we cover every possibly ambiguity, the tutorial will be much harder to grasp for the majority of people. |
Thanks for the easy example @Prinzhorn. Somehow my solution did not work, but yours works great! My only issue left is that the select field will be empty when a null value is supplied, even though there is no empty option?! That behaviour is different from normal plain select fields as they will just default to the first option. It happens only with Svelte routing, not on the first load from server, there the first option is in the select box. Sadly it's not reproducible with your code in REPL. I will just set undefined values to "" or a default to make it work. |
DON'T KNOW MUCH AS I AM BEGINNER. DOES THIS WORK FOR THIS..... |
Describe the problem
The tutorial "use bind:value with elements" does not show how the input can be used to pre-select an option. Does that need to be done manually with setting selected in one of the options? Or does the binding have some smart way to do the pre-select automatically for easy two-way binding? Describe the proposed solution Expand the documentation Alternatives considered n/a Importance would make my life easier
The text was updated successfully, but these errors were encountered: