select2 - hiding the search box

前端 未结 18 1934
太阳男子
太阳男子 2021-01-29 19:04

For my more significant selects, the search box in Select2 is wonderful. However, in one instance, I have a simple selection of 4 hard-coded choices. In this case, the search bo

18条回答
  •  萌比男神i
    2021-01-29 19:29

    Version 4.0.3

    Try not to mix user interface requirements with your JavaScript code.

    You can hide the search box in the markup with the attribute:

    data-minimum-results-for-search="Infinity"

    Markup

    
    

    Example

    $(document).ready(function() {
      $(".select2").select2();
    });
    
    
    
    
    
    
    
    
    

提交回复
热议问题