【问题标题】:Select2 not selecting when has just one optionSelect2 只有一个选项时不选择
【发布时间】:2016-03-25 18:03:04
【问题描述】:

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

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>

谢谢

【问题讨论】:

    标签: jquery twitter-bootstrap-3 select2


    【解决方案1】:

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

    【讨论】:

    • 感谢@kevinBrown!
    猜你喜欢
    • 1970-01-01
    • 2018-11-09
    • 1970-01-01
    • 2016-10-20
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多