htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.91k stars 309 forks source link

Advanced Select not working in Nuxt.js (Vue.js) #325

Closed oliver-savi closed 2 months ago

oliver-savi commented 7 months ago

On first load, the select component gets rendered correctly. If page or component in v-if change, then it reinitializes the select and adds double element. I have followed the steps from framework guides, but the solution there does not even initialize it on first load.

plugins/preline.client.ts:

import 'preline/preline'

declare var HSStaticMethods: {
  autoInit(collection?: string | string[]): void
}

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hook('page:finish', () => {
    setInterval(() => {
      HSStaticMethods.autoInit()
    }, 1000)
  })
})

After second load of component, it will look like this:

image

EDIT: Added a basic demo: https://nuxt-preline-test.netlify.app/test Code: https://github.com/oliver-savi/preline-test

langscot commented 3 months ago

Try running HSStaticMethods.cleanCollection() before your autoInit call.

jahaganiev commented 2 months ago

Hey @oliver-savi - please check out the latest version, the issue has been fixed. Thanks!