How to Use Select2 in Bootstrap Modal with jQuery?

I’m trying to use the Select2 plugin, while the plugin works perfectly in other places, I’m unable to use it within a Bootstrap modal. I’m using Select2 like this:


But it’s not working as expected within the bootstrap modal. I am unable to search or select. How can I make it work?

You need to define a dropdownParent property in the Select2 plugin.

    dropdownParent: $('#products-modal')

This should solve your problem.