Initial value binding to select multiple in Vuejs not working #141
Replies: 2 comments
-
I notice you're binding on the options, but the Shoelace docs for Vue show two-way binding a bit differently: <!-- This doesn't work -->
<sl-input v-model="name"></sl-input>
<!-- This works, but it's a bit longer -->
<sl-input :value="name" @input="name = $event.target.value"></sl-input> Unlike the native <wa-select :value="name" @input="name = $event.target.value"></wa-select> For As for why things work differently, it's likely due to the form associated custom element integration we added to Web Awesome to make its form controls first-class citizens via ElementInternals, which wasn't available when Shoelace was created. |
Beta Was this translation helpful? Give feedback.
-
Many thanks for your quick response. I'm not binding to the
Does your answer mean that the
That's also why I assumed that |
Beta Was this translation helpful? Give feedback.
-
I'm having a strange issue when trying to bind a value to a
<wa-select multiple>
. What I'm doing is this:What I observe is that when I initialize the selection after my Vue component has mounted, then the values of the selection are not displayed in the
<wa-select>
. If afterwards theselection
changes, then the<wa-select>
immediately shows all the selected options.When I do the same with an
<sl-select>
like in the following code, then it works and the selection is displayed after the initialization:Also, when I explicitly use
v-bind:value.attr
on the<wa-select>
and set the values as space-delimited strings, then it works too (this also works with sl-select):I don't understand why there is this difference between Shoelace and Webawesome and whether there is something I'm doing wrong with Webawesome or whether this is a bug.
I tried to create an example demonstrating the problem but I didn't get it to run in Codepen or Vue Playground with the required setup (isCustomElement).
Beta Was this translation helpful? Give feedback.
All reactions