在Select2选择中选择一个选项会导致以下Select2打开

时间:2019-04-22 18:33:25

标签: jquery-select2

使用我的Select2插件查找奇怪的事件。我的页面上有3个Select2插件,第一个选择任何选项都会导致第二个Select2打开,与下一个Select控件相同。

只是想知道是否有人看到可能导致这种情况的东西?

 $('#JournalistId').select2();
 $('#PublicationId').select2();

<div class="col-sm-5">
@Html.LabelFor(m => m.PublicationId, new { @class = "control-label" })
@Html.DropDownListFor(m => m.PublicationId, (SelectList)ViewBag.Publications,
"-- Please Select --", new { @class = "select2 form-control" })
</div>
<div class="col-sm-4">
 @Html.LabelFor(m => m.JournalistId, new { @class = "control-label" })
@Html.DropDownListFor(m => m.JournalistId, (SelectList)ViewBag.Journalists,
 "-- Please Select --", new { @class = "form-control" })
</div>    
  

呈现的HTML

<div class="col-sm-5">
<label class="control-label" for="PublicationId">PublicationId</label>
<select class="select2 form-control select2-hidden-accessible" data-val="true" data-val-number="The field PublicationId must be a number." id="PublicationId" name="PublicationId" data-select2-id="PublicationId" tabindex="-1" aria-hidden="true">
<option value="">-- Please Select --</option>
<option value="54"></option>
</select>
<span class="select2 select2-container select2-container--default" dir="ltr" data-select2-id="3" style="width: 357.5px;">
<span class="selection">
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-PublicationId-container">
<span class="select2-selection__rendered" id="select2-PublicationId-container" role="textbox" aria-readonly="true" title="Ottawa Sun">Ottawa Sun</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>
<div class="col-sm-4">
<label class="control-label" for="JournalistId">Author</label>
<select class="form-control select2-hidden-accessible" data-val="true" data-val-number="The field Author must be a number." id="JournalistId" name="JournalistId" data-select2-id="JournalistId" tabindex="-1" aria-hidden="true">
<option value="" data-select2-id="2">-- Please Select --</option>
<option value="269"></option>
<option value="28">2</option>
<option value="449">1</option>
</select><span class="select2 select2-container select2-container--default" dir="ltr" data-select2-id="1" style="width: 279.984px;">
<span class="selection">
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-JournalistId-container">
<span class="select2-selection__rendered" id="select2-JournalistId-container" role="textbox" aria-readonly="true" title="-- Please Select --">-- Please Select --</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>

0 个答案:

没有答案