Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

Metronic components not working in Vue Router


Hi, I've followed this guide to integrate Metronic 9 with Vuejs. I'm running Vue router so, as mentioned in the guide, I'm initializing KTComponent like this:

// index.ts
import KTComponent from '../metronic/core/index.ts;
import KTLayout from '../metronic/app/layouts/demo1.js';

router.beforeEach(() => {
KTComponent.init();
KTLayout.init();
});


However, when I try running a component inside a view it doesn't work. When I paste a tooltip inside a view, for example:

<button class="btn btn-primary" data-tooltip="#default_tooltip">
Toggle Tooltop
</button>
<div class="tooltip" id="default_tooltip">
Hey, a delightful tooltip is here!
</div>


It doesn't work. But if I initialize the component like this it works:


import KTTooltip from '../metronic/core/index.ts';
KTTooltip.init()


There must be an issue in the way components are getting initialized inside KTComponent.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


@slither io what do you think about this case



Hi,

Thank you for the heads-up. We will check it further and get back to you shortly.

Regards.



Hey! Any updates on the above?



Hi,

Sorry for the late reply.

May I know which version you are using? Have you checked it with the latest Metronic v9.0.3 ?

We have also updated the React Integration Guide and React Starterkit as well.

Regards,
Sean



Hi,

Sorry for the late reply.

We have tried using our tooltip component on react-router page and tooltips get initialized correctly.

Do you still have the `KTTooltip.init()` trigger in the function KTComponent.init()?

Are you getting any errors in your browser console?

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(