select2 - hiding the search box

前端 未结 18 2052
太阳男子
太阳男子 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条回答
  •  我在风中等你
    2021-01-29 19:28

    For multiselect you have to write js code, there is no settings property.

    $('#js-example-basic-hide-search-multi').select2();
    
    $('#js-example-basic-hide-search-multi').on('select2:opening select2:closing', function( event ) {
        var $searchfield = $(this).parent().find('.select2-search__field');
        $searchfield.prop('disabled', true);
    });
    

    This mentioned on their page: https://select2.org/searching#multi-select

提交回复
热议问题