Select2 不选择时只有一个选项
Select2 not selecting when has just one option
我正在使用带占位符的 select2,问题是当我在 select 控件中只有一个选项时,我不能 select 它。当我单击该选项时,它总是显示占位符。似乎第一个选项已经 selected。
<div class="form-group ">
<label class="control-label requiredField" for="contatoCondominio">
Requisitante <span class="asteriskField">*</span> <i class="fa fa-circle-o-notch fa-spin" style="visibility: hidden;" id="contato-loading"></i>
</label>
<select class="select form-control select2-hidden-accessible" id="contatoCondominio" name="contatoCondominio" tabindex="-1" aria-hidden="true">
<option value="14">Nome do Sindico</option>
</select>
<span class="select2 select2-container select2-container--bootstrap select2-container--below" dir="ltr" style="width: 988px;">
<span class="selection">
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-contatoCondominio-container">
<span class="select2-selection__rendered" id="select2-contatoCondominio-container">
<span class="select2-selection__placeholder">Selecione um opção</span>
</span>
<span class="select2-selection__arrow" role="presentation">
<b role="presentation"></b>
</span>
</span>
</span>
<span class="dropdown-wrapper" aria-hidden="true"></span>
</span>
</div>
谢谢
您缺少使用占位符时所需的空白选项。无法选中单个结果,因为它已被浏览器自动选中,Select2 不知道如何处理。
我正在使用带占位符的 select2,问题是当我在 select 控件中只有一个选项时,我不能 select 它。当我单击该选项时,它总是显示占位符。似乎第一个选项已经 selected。
<div class="form-group ">
<label class="control-label requiredField" for="contatoCondominio">
Requisitante <span class="asteriskField">*</span> <i class="fa fa-circle-o-notch fa-spin" style="visibility: hidden;" id="contato-loading"></i>
</label>
<select class="select form-control select2-hidden-accessible" id="contatoCondominio" name="contatoCondominio" tabindex="-1" aria-hidden="true">
<option value="14">Nome do Sindico</option>
</select>
<span class="select2 select2-container select2-container--bootstrap select2-container--below" dir="ltr" style="width: 988px;">
<span class="selection">
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-contatoCondominio-container">
<span class="select2-selection__rendered" id="select2-contatoCondominio-container">
<span class="select2-selection__placeholder">Selecione um opção</span>
</span>
<span class="select2-selection__arrow" role="presentation">
<b role="presentation"></b>
</span>
</span>
</span>
<span class="dropdown-wrapper" aria-hidden="true"></span>
</span>
</div>
谢谢
您缺少使用占位符时所需的空白选项。无法选中单个结果,因为它已被浏览器自动选中,Select2 不知道如何处理。