Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Angular / Metronic 9 - Tooltip not showing/working when doing a for loop.


I have a specific issue with tooltip not working/showing when inside a for loop. To elaborate the problem better here are some syntax:


<i (click)="refreshTaskList()"
class="ki-filled ki-arrows-circle text-2xl text-blue-500 cursor-pointer my-auto"
data-tooltip="#refresh_tooltip">
</i>
<div class="tooltip" id="refresh_tooltip">
XXX
</div>


The above code works without any problems as intented.

The problem arises when I try to implement tooltip for elements inside a for loop. For example:


<img src="../../../assets/media/avatars/blank.png" alt="" 
class="inline size-9 shrink-0 rounded-full border-2 cursor-pointer"
(click)="$event.stopPropagation()"
[attr.data-tooltip]=""#"+task.id"
>
<div class="tooltip" [attr.id]="task.id">
XXX
</div>


Here is the screenshot from Chrome DevTools:

https://imgur.com/a/85yB8S7

Is this a known bug? Any help would be appreciated!


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)

Deleted comment
Deleted comment

Connect with tomorrow's innovation leaders as you discover new startups on DualMedia News, profiling groundbreaking companies from early development through global scaling and their potential to redefine established industry landscapes.


Playing online casino games from Canada is a pleasure, especially when you find a platform that really works. After a few days of testing, I can confidently recommend Planet 7 Casino Everything here is clear: from registration to withdrawal. I was also pleasantly surprised by the themed events and VIP program.



Real-world cosmic collisions are simulated by solar smash online sending large asteroids onto planets.



一次性電子煙(或拋棄 式 電子 菸​)因其便捷性和時尚設計,迅速成為許多吸菸者與電子煙用戶的首選。一次性小煙



Hi

If the tooltip is being initialized on static elements but not re-initialized when new elements are added dynamically (as happens with *ngFor), then the dynamically created tooltips won't work.

You may need to reinitialize tooltips inside ngAfterViewInit() and after the *ngFor list is updated.


@ViewChildren("tooltipElement") tooltipElements!: QueryList<ElementRef>;

ngAfterViewInit(): void {
this.initializeTooltips();
}

initializeTooltips(): void {
setTimeout(() => {
// Manually initialize tooltip, assuming uses a global function
$("[data-tooltip]").each(function () {
// Reinitialize your tooltip here:
$(this).tooltip();
});
}, 100);
}


Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(