Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

Select2 when in a modal out of position


Hi everyone,

I'm having trouble displaying a Select2 dropdown inside a modal in my project. The dropdown is always misaligned and appears outside its intended position.

I've taken a screenshot: https://ibb.co/qdTDRzq

Using Metronic 8

Any ideas on how to solve this?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


Hi,

Please check Metronic Select2 with Modal guide to properly use Select2 inside Modals by passing data-dropdown-parent="#kt_modal_1" to the Select2 element.

Regards,
Sean



I have follow the documentation,

So it is all configured,

<select name="business_form[country]" aria-label="Select a Country" data-control="select2" data-placeholder="Select a Country..." data-dropdown-parent="#kt_modal_add_business" class="form-select form-select-solid fw-bold select2-hidden-accessible" data-select2- tabindex="-1" aria-hidden="true" data-kt-initialized="1">

modal:
<div class="modal fade" tabindex="-1" aria-hidden="true">



I have follow the documentation, however still not working, and have tried everything to align the select2

<select name="business_form[country]" aria-label="Select a Country" data-control="select2" data-placeholder="Select a Country..." data-dropdown-parent="#kt_modal_add_business" class="form-select form-select-solid fw-bold select2-hidden-accessible" data-select2- tabindex="-1" aria-hidden="true" data-kt-initialized="1">

modal:
<div class="modal fade" tabindex="-1" aria-hidden="true">



Hi,

Is this example working for you?

Will it be possible to send us a test URL in a private reply?

Regards,
Sean


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(