
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
nuxt3-select2
Advanced tools
select2 for nuxt3. https://github.com/jackysupit/nuxt3-select2/tree/for-nuxt3
This is a select2 component for nuxt3 based on godbasin work here: vue3-select2-component credits belong to them for making all these availble for us for free.
// npm install
npm install nuxt3-select2 --save
// plugins/select2.client.ts
import Select2 from 'nuxt3-select2';
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component("Select2", Select2, {});
});
// use it
<template>
<div>
<Select2 v-model="myValue" :options="myOptions" :settings="{ settingOption: value, settingOption: value }" @change="myChangeEvent($event)" @select="mySelectEvent($event)" />
<h4>Value: {{ myValue }}</h4>
</div>
</template>
<script setup lang="ts">
const myChangeEvent = (event) => {
console.log("myChangeEvent: ", event);
}
const mySelectEvent = (e) => {
console.log("mySelectEvent: ", event);
}
const myOptions = [
{id: 1, text: 'apple'},
{id: 2, text: 'berry'},
{id: 3, text: 'cherry'},
]
const myValue = ref();
</script>
options
: option[]
option
: {id: key, text: value}
or string
v-model
: option value that is selected
id
or string
while multiple is disableid[]
or string[]
while multiple is enabledisabled
placeholder
id
name
settings
setting
: { settingOption: value, settingOption: value }
currently supporting these events:
change
:= changeclosing
:= select2:closingclose
:= select2:closeopening
:= select2:openingopen
:= select2:openselecting
:= select2:selectingselect
:= select2:selectunselecting
:= select2:unselectingunselect
:= select2:unselectclearing
:= select2:clearingclear
:= select2:clearFor the complete documentation, see on Select2 Event API
Here is how I manage it works:
<div class="input-group">
<Datepicker class="my-control" />
<Select2 class="my-control"/>
</div>
Putting form-control class is ok, but it will create borders, while I don't want to have that border. So I create my own class: my-control. It's optional of course.
here is the css:
.input-group .select2-container {
height: 37px;
}
.input-group .select2-container .selection .select2-selection--single {
height: 100%;
}
/* optional, you can use form-control if you prefer */
.input-group .my-control {
position: relative;
flex: 1 1 auto;
width: 1%;
min-width: 0;
}
there are 30 solutions (wow :) here: https://stackoverflow.com/questions/18487056/select2-doesnt-work-when-embedded-in-a-bootstrap-modal
but sadly few top answers just doesn't work for me. Instead, I did a little trick, and it worked. just override the z-index
.select2-container.select2-container--default.select2-container--open {
z-index: 9999;
}
you don't have to make it 9999. at least the modal z-index + 1 is enough.
somehow after npm run build, the jquery and select2 doesn't work
(warning: it's not recommended to add jquery to vuejs application. so take it at your own risk basically, all you need to do in jquery, you should be able to do it in vue. all you need to do is a little more googling and stackoverflowing :'' )
add this in the nuxt-config.ts
app: {
head: {
script: [
{src: '/_nuxt/node_modules/jquery/dist/jquery.js'},
{src: '/_nuxt/node_modules/select2/dist/js/select2.min.js'},
],
},
css: [
"/_nuxt/node_modules/select2/dist/css/select2.min.css",
],
FAQs
select2 for nuxt3. https://github.com/jackysupit/nuxt3-select2/tree/for-nuxt3
The npm package nuxt3-select2 receives a total of 49 weekly downloads. As such, nuxt3-select2 popularity was classified as not popular.
We found that nuxt3-select2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.