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

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