Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

How to toggle model or drawer based on a Pinia store state?


Hi, I'm using Mertonic Vue and I changed things up a bit in this project using Pinia with it. If I want a model or drawer to be shown based on the Pinia store state or maybe update the store state when a modal or drawer is toggled, how will I do that?

With regular javascript, I can simple use the Model class or the jQuery attribute to toggle a certain modal like in the bootstrap documentation so is there a helper or something for the Vue.js version of metronic?


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


Hi,

We are planning to migrate our Metronic 8 Vue version to Pinia and Vite in the next release.

You can get a drawer instance for a drawer in your component and then use the show function to show the drawer.

import { DrawerComponent } from "@/assets/ts/components";

const drawer = DrawerComponent.getInstance("your_drawer_id");
drawer?.show();


You can do the same with the modal window instance.

import { Modal } from "bootstrap";

if (modalEl.value) {
const myModal = new Modal(modalEl.value);
myModal.show();
}



Regards,
Lauris Stepanovs,
Keenthemes Support Team



Thank you Lauris, that's kinda what I was looking for. It's gonna include a lot of extra code this way but I can't wait for the Pinia and Vite update - that's what I'm using for my project at the moment, I've overridden most the pre-built Vuex stores and it works wonders.

Metronic 8 really is a beautiful and performant project.



Hi,

Glad to hear that. All the best with your project!

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
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  :(