According to the documentation, I should be able to set some configuration via data-attributes on the select tag.
https://select2.org/configuration/data-attributes
In my code, I tried this:
<select id="customer_select_form_customer" name="customer_select_form[customer]" class="select2-ajax-enabled form-control" style="width: 500px" data-theme="bootstrap4" data-ajax--url="/customer/ajaxList" data-ajax--cache="true" data-select2-id="customer_select_form_customer" ></select>
I tried to initialize this with the following, but it does nothing:
// enable the customer ajax list $('.select2-ajax-enabled').select2({});
I also tried to set the parameters, and have them override, but that didn’t work either:
// enable the customer ajax list $('.select2-ajax-enabled').select2({ theme: 'bootstrap4', minimumInputLength: 3, ajax: { url: '', dataType: 'json', cache: 'true' } });
Is there a configuration/setting that I’m missing to get the data attributes to work?
If I specify the whole config and pass it to select2, it works as expected.
I’m using jQuery v3.3.1 and Select2 4.0.6-rc.1