Replies: 6 comments 4 replies
-
Have you tried setting the default value to an empty string instead of null? |
Beta Was this translation helpful? Give feedback.
-
Yes, check the example, empty string and null have same results. |
Beta Was this translation helpful? Give feedback.
-
You can use `:disabled="true"` instead of `disabled`.
x-model while try to set the select to the matching value when Alpine kicks
in but, being disabled, it will select the next available option.
Whit the suggested change, alpine will add the disabled attribute after
…On Thu, 31 Dec 2020, 00:28 Jeremy Holstein, ***@***.***> wrote:
Have you tried setting the default value to an empty string instead of
null?
@ryangjchandler <https://github.com/ryangjchandler>
Yes, check the example, empty string and null have same results.
It works fine if you don't use the disabled prop.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#970 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAJRWP3PHUNDYEW43M6ULDSXPATXANCNFSM4VOZP4UQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Ran into a situation where I made a codepen to show this https://codepen.io/colinaut/pen/wvJENbx |
Beta Was this translation helpful? Give feedback.
-
Found a solution! Instead of |
Beta Was this translation helpful? Give feedback.
-
I'm still experiencing issues with this if have a select field where you need to combine a default 'please choose' option with dynamically loaded options in a as below. Even if the x-model is pre-populated with one of the option values, it won't bind and will still default to the 'please choose' option.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
If you have a select input with a default option using
value="" selected disabled
andx-model
with a null value, it will not default to that first option. Without thex-data
it works fine.https://codepen.io/jjjrmy/pen/gOwvRBg?editors=1000
On the example the Year input has the desired results. Only the ones using Alpine are not behaving correctly.
"alpinejs": "^2.8.0",
Beta Was this translation helpful? Give feedback.
All reactions