Drawer metronic : data-kt-drawer
How can I open/close a drawer via a method call?
I'd like to be able to generate drawers and open/close them using a method that would be called after various actions.
At present, it seems that the drawer can only be opened via a button that has a src=“ID” which is equal to the drawer ID.
Replies (1)
Hi,
Thank you for reaching out to us.
To open or close drawer from javascript code you should get a drawer instance in your component and then open it using show and close using hide function as shown in the example below.
import { DrawerComponent } from "@/assets/ts/components";
const drawer = DrawerComponent.getInstance("your_drawer_id");
drawer.show();
drawer.hide(); Please let us know if you have any further questions on this topic or anything else.
Regards,
Lauris Stepanovs,
Keenthemes Support Team