Vue.js disable/enable dropdown menu if checkbox is checked?
P粉714844743
2023-08-29 23:14:07
<p>I'm trying to enable/disable dropdown:combination selection when my box is checked.
It works fine when I <strong>Add Name</strong> but when <em>Clientless</em> is selected, it doesn't work in <strong>Edit Name</strong> work. </p>
<p>The dropdown should be disabled because "Clientless" is selected, and should only be enabled if I uncheck the box. However, when the box is checked, the dropdown menu is enabled, and when I uncheck the box, the dropdown menu is disabled. </p>
<p>
<pre class="brush:js;toolbar:false;">data: {
editSelect: true,
},
methods: {
noClient()
{
this.editSelect = !this.editSelect;
},</pre>
<pre class="brush:html;toolbar:false;"> <b-form-checkbox
id="noName"
v-model="team.nameId"
name="noName"
type="checkbox"
:value="null"
@change="noName()"
/>
<combo-select
id="nameBox"
v-model="team.nameId"
api-location="fetchTeamsByName"
api-details-location="fetchTeamDetails"
search-parameter="name"
:additional-search-fields="additionalSearchField"
:transformer="nameTransformer"
:value="null"
:config="{
...comboConfig,
searchLabel: 'Search names',
isEditable: editSelect,
}"
class="input input__typeahead"
@on-select-item="onTeamComboSelect"
/> </pre>
</p>
<p>Please help me understand what is wrong with my code. Also, if you have any suggestions on how I should code this problem differently, please let me know! </p>
You can set
v-model
on the checkbox and use that value to disable the dropdown.