Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select2 always shows "No results found" message

I need to create select2 where I can select multiple values. But I'm getting "no results found" message everytime, tried various solutions but nothing worked. I really don't have idea what's wrong.

<select id="keywords-input" multiple="multiple" style="width:300px">
    {*
    <option selected="selected" value="Val 1">Val 1</option>*} {*
    <option selected="selected" value="Val 2">Val 2</option>*} {*
    <option selected="selected" value="Val 3">Val 3</option>*} {*
    <option selected="selected" value="Val 4">Val 4</option>*} {*
    <option selected="selected" value="asfsafafsa">asfsafafsa</option>*}
</select>

<script>
    $(document).ready(function() {
        $('#keywords-input').select2({
            tags: true,
            tokenSeparators: [',', ' '],
            data: ['Val1', 'Val2', 'Val3'],
            maximumInputLength: 10,
            multiple: true
        });
    });
</script>

The result

like image 787
Honza Bednář Avatar asked Oct 29 '25 07:10

Honza Bednář


1 Answers

It was caused by another javascript that used select2 class, now it works. So it my code wasn't wrong.

like image 76
Honza Bednář Avatar answered Oct 31 '25 12:10

Honza Bednář



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!