Vue directive for avoiding PrimeVue Listbox component to set a null value when an option is already selected.
WARNING: This directive has only been test on Listbox PrimeVue component, but it should work on components which use the updateModel
method to update their model.
- Create a plugin in nuxt plugins folder.
- Add the following code to install the directive:
import PrimeVueMandatory from '@carodriguezg/primevue-mandatory'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(PrimeVueMandatory)
})
- Add
v-mandatory
on the component:
<Listbox v-mandatory :options="your_items" />
- Enjoy!