代码之家  ›  专栏  ›  技术社区  ›  Yagami Light

使用Select2禁用自动完成输入

  •  0
  • Yagami Light  · 技术社区  · 6 年前

    SELECT2

    <select  class="js-example-basic-single" id="existeField">
        <option value="" disabled selected>Selectionnée le
                                        champs</option>
        <option th:each="fields: ${listFields}" th:value="${fields.id}"
            th:data-jira="${fields.idJira}" th:data-type="${fields.type}"
            th:data-defaut="${fields.value}" th:text="${fields.nom}">
       </option>
    </select> 
    
    
    
    <script>
        $(document).ready(function() {
            $(".js-example-basic-single").select2();   
    
        });
    </script>
    

    而且它的输入也不是很好

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   Yagami Light    6 年前

    问题不在 SELECT2 但它是在模态(这是一个标准的引导模态)

      <div class="modal fade" id="exampleModal" name="exampleModal"
                    tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                    aria-hidden="true">
                    <div class="modal-dialog" role="document">
    
      ....
    

    解决办法是简单地删除 tabindex="-1" 一切都会好起来的 .