Your support helps keep this blog running! Secure payments via Paypal and Stripe.
Yii version 2.0.13.1
The Select2 plugin is a very useful plugin when you are building a custom application or website.
Problem
When I use Select2 inside a Bootstrap modal. I can not type anything in the input field that attaches to the plugin.
Cause
This issue occurs because the Bootstrap modal tends to steal focus from other elements outside of the modal. Since by default, Select2 attaches the dropdown menu to the <body> element, it is considered “outside of the modal“.
Solution
Attach the dropdown to the modal itself with the dropdownParent setting:
Example
$('#mySelect2').select2({
dropdownParent: $('#myModal')
});If you use Select2 on the main page where you trigger the Bootstrap modal, you just add dropdownParent to <body>.
Your support helps keep this blog running! Secure payments via Paypal and Stripe.

