选择2不选择何时只有一个选项

时间:2016-03-25 18:03:04

标签: jquery twitter-bootstrap-3 select2

我正在使用带占位符的select2,问题是当我在select控件中只有一个选项时,我无法选择它。当我点击该选项时,它总是显示占位符。似乎已经选择了第一个选项。

This is how I see the option

<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>

由于

1 个答案:

答案 0 :(得分:1)

使用占位符时,您缺少所需的空白选项。无法选择单个结果,因为浏览器已自动选择该结果,而Select2不知道该怎么做。

相关问题