Prevent select2 from autmatically focussing its search-input when dropdown is opened

后端 未结 10 448
野性不改
野性不改 2021-01-11 16:02

I\'m looking for a way to prevent select2\'s search-input being automatically focussed when the select2-dropdown is opened. I know this is select2\'s intended default behavi

10条回答
  •  情话喂你
    2021-01-11 16:38

    Following trick worked for me. You can disable input search field of select2 element :

    $('select').on('select2:opening', function() {
      $('.select2-search__field').attr("autocomplete", "new-password");
    });
    
    setTimeout(function(){ $('.select2-search__field').attr("autocomplete", "new-password"); }, 2000);
    

提交回复
热议问题