cannot read property 'id' of undefined select2

前端 未结 2 1634
情歌与酒
情歌与酒 2021-02-02 10:37

I used Select2 4.0.6, I have a bug like below:

allowClear gives \"Uncaught TypeError: Cannot read property \'id\' of undefined\" when used on select.

How can I f

2条回答
  •  爱一瞬间的悲伤
    2021-02-02 11:03

    In my case data-placeholder helped as shown below:

    Select element:

    
    

    JS:

    $('.select2').each(function(){
        var select = $(this);
        select.select2({
             width: '100%',
             allowClear: !select.prop('required'),
             language: {
                noResults: function () {
                    return "{{ __('No results found') }}";
                }
            }
        });
    });
    

提交回复
热议问题