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

Select2 field in Laravel Vue3 metronic 8 demo 1


Hi,

I'm trying to add a select field with the FIeld component of the vee-validate library, but it keeps displaying a simple select field.

I added these attributes on the Field component: class="form-select form-select-solid" data-control="select2" data-hide-search="true" as="select"

What I should do to init select2? What I'm missing there?

Thanks in advance,
Vahan


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 (3)


Hi,

Please note that the Select2 plugin requires jQuery, and combining jQuery with a Vue application is not considered good practice. Therefore, it is not included in our Metronic Vue version by default. However, you can install the jQuery and Select2 dependencies and use Select2 in Vue by following the installation instructions in the official Select2 documentation.
https://select2.org/getting-started/installation

Then you can refer to the usage examples in our documentation.
https://preview.keenthemes.com/html/metronic/docs/forms/select2

Also, as an alternative to Select2 in the Metronic Vue version, you can use the Vue-Multiselect plugin or the Element Plus select component.

Regards,
Lauris Stepanovs,
Keenthemes Support Team



Hi Lauirs,

Thank you, I checked this page and used it.

Now I have a new question: is there a ready-made select2 field that can load more on scroll?

Thank you in advance,
Vahan



Hi,

You can find an example of infinite scroll in select2 official docs.
https://select2.org/data-sources/ajax

Regards,
Lauris Stepanovs,
Keenthemes Support Team


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  :(