X-Model on select not binding to 'value' on page start #1255
Replies: 3 comments
-
This looks like it should work. Note that when using In that case and in your case what would help is to bind the <option x-bind:selected="tripData.clientOrder.operationType === 'transfer'" value="transfer">Cruce</option>
<option x-bind:selected="tripData.clientOrder.operationType === 'linehaul'" value="linehaul">Viaje</option>
<option x-bind:selected="tripData.clientOrder.operationType === 'drayage'" value="drayage">Movimiento Local</option> |
Beta Was this translation helpful? Give feedback.
-
If this isn't in the docs already, it would be great if we could get an official word on whether this is the correct technique from anyone (or @calebporzio if possible?) — I've just implemented similar (specifically with options populated using |
Beta Was this translation helpful? Give feedback.
-
You could try something like <select x-model="selected" x-init="$el.value='default value'"> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
So, I have a typical select with the x-model attribute like so:
The thing is the alpine property is being bound to what is inside the tag, not what's specified on the [value] attribute.
If I change the selection, it correctly binds to the [value] attribute, but in some cases (most of them) the default selection is what's required.
Am I doing something wrong?
TIA!
Beta Was this translation helpful? Give feedback.
All reactions