模态中的select2不可聚焦

时间:2018-05-15 00:07:30

标签: jquery bootstrap-modal jquery-select2

我有这个HTML

    <div id="create" class="modal fade" role="dialog">
        <div class="modal-dialog">  
            <div class="modal-content">
           <div class="modal-header">
           </div>
<div class="modal-body">
  <select class="form-control select" name="list" id="list" 
        placeholder="SelectList" required>
   <option value="">Select List</option>
   <option value="">one</option>
   <option value="two">two</option>
   <option value="three">three</option>                                       
</select>
     </div>

              $(document).ready(function(){
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
$('.select').select2({
                dropdownParent: $('#create')
            });

}):

我尝试在堆栈溢出中寻找答案他们确实有一些答案,因为我已经实现了上面但它似乎没有工作

1 个答案:

答案 0 :(得分:0)

<i>
<style type="text/css">
        .modal-open .select2-container--open { z-index: 999999 !important; width:100% !important; }
    </style>
</i>

为我工作