I have a hard time to make tootips working in loop. I am using vuejs3, tailwindcss3, and flowbite. I would like to use tooltip on my button for additional information.
When I used hard coded id, tooltip works great, but when I tired to use the tooltip with id and data-tooltip-target assigned pragmatically in a loops, tooltip is not working when first time page loaded.
<li v-for="(shift, idx) in shiftsMatrix" :key="idx" class="relative flex cursor-pointer" :class="`col-start-${shift.x}`" :style="`grid-row: ${shift.y}`" @click="showUpdateSchedule(shift.self)" >
<div
:data-tooltip-target="`tooltip-${shift.self.id}`" data-tooltip-style="light"
class="group absolute inset-1 z-30 flex items-center rounded px-1 text-xs truncate overflow-x-hidden leading-5"
:class="['TO', 'SL'].includes(shift.shift_role) ? 'bg-gray-100' : storeStore.branchColors[shift.branch % 11]"
>
<p class="text-gray-900 font-medium group-hover:text-red-900 mx-auto">
<span>{{ shift.time }}</span>
<span v-if="shift.shift_role==='OW'">✭</span>
</p>
</div>
<div v-if="shift.self.note" :id="`tooltip-${shift.self.id}`" role="tooltip" class="absolute z-50 invisible inline-block px-3 py-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 tooltip">
{{ shift.self.note }}
<!-- <div class="tooltip-arrow" data-popper-arrow></div> -->
</div>
</li>
Weird thing is that it starts to work after I have been to different pages even though lots of errors in a console, saying index.ts:243 The tooltip element with id "tooltip-519" does not exist. Please check the data-tooltip-target attribute.
How can I make this works in a loop?
Thanks in advance...