Robin
Robin

Reputation: 164

jQuery Select2 not closing anywhere (also not on their own website)

I have built this select2 ajax dropdown and after finishing it i figured it didn't close after opening. Looking for a solution I came across the official website (select2.org) and also here the dropdowns won't close after opening.

This is my code:

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6/js/select2.min.js"></script>
    $('#prescriber_id').select2({
        ajax: {
            url: 'prescribers/dropdown_search',
            delay: 250, // wait 250 milliseconds before triggering the request,
            dataType: 'json',
            data: function (params) {
                var query = {
                    search: params.term,
                    page: params.page || 1
                }

                // Query parameters will be ?search=[term]&page=[page]
                return query;
            }
        }
    });

Also i tried adding "closeOnSelect: false". But that didn't change a thing. Anything else works fine.

Does anyone know what's going on? Am i doing something wrong?

Upvotes: 4

Views: 2449

Answers (1)

Robin
Robin

Reputation: 164

Apparently this is a known bug occurring on single select boxes with version 4.0.6. It is fixed in 4.0.7-rc.0

Upvotes: 5

Related Questions