I am using select2 to set the dropdownautowidth
to true on my SharePoint search page and it works perfectly on page load for the first time. After i search for some keyword, the page loads with search results and then dropdownautowidth is not setting true by somehow. I am using $('#ddlCategory').select2({dropdownAutoWidth : true});
statement on my document.ready
function.
Any help is appreciated.
This worked for me:
$('select').select2({
dropdownAutoWidth : true,
width: 'auto'
})
you need to quote it, like:
$('#ddlCategory').select2({dropdownAutoWidth: 'true'});
this works for me.
In select2 4.0.0 this will not work for me, either. I use this workaround:
$('select').select2();
The css:
select + .select2-container {
width: 100% !important;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With