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

Tooltips doesn't work in Blazor Components


Hi, I am using Blazor Metronic Templates. Tooltips doesn't work in components because components add content dynamically to dom.

Kindly guide me how can I resolve this problem to show tooltips in Blazor Components


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 (2)


To make tooltips work in Blazor components using Metronic templates, you need to initialize them manually after the content is dynamically added to the DOM. Since Blazor renders components dynamically, the tooltips may not be automatically recognized. You can resolve this by calling Bootstrap.Tooltip via JavaScript after the component has rendered. Use JSRuntime.InvokeVoidAsync("eval", "new bootstrap.Tooltip(document.body, { selector: '[data-bs-toggle=\"tooltip\"]' })"); inside OnAfterRenderAsync. This ensures tooltips get initialized properly. If you need more insights on Blazor development, Weboutride Games also provides useful guides and resources.



Hi,

You just need to call the global component initializer API function whenever you add a component dynamically:


KTComponents.init()


Regards,
Sean


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  :(