Reputation: 13
I'm using select2 with placeholder, the problem is when I have just one option in the select control, I can't select it. When I click on the option it always shows me the placeholder. It seems like the first option is already 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>
Thanks
Upvotes: 1
Views: 1842
Reputation: 41699
You're missing the blank option required when using a placeholder. The single result can't be selected because it has automatically been selected by the browser and Select2 doesn't know what to do.
Upvotes: 2