In
I need to maintain the state of the Aside Menu between requests. I noticed that when the toggle is used to minimize the aside menu a cookie is set.
Is this cookie suposed to restore de minimized state of the toogled menu? is there any way to persist or restore the state of the menu between requests?
thanks!
Worked great! thank you
Hi,
You can use the KTToggle Events API to safe the toggle state in Cookie and in server side you can access to the Cookie value and toggle the Aside state during the page generation check sidebar_minimize_state
cookie value in server side and add data-kt-aside-minimize="on"
to the body element and add active
class to the toggle element.
Go to src/js/layout/sidebar.js
and add
// Private functions
var handleToggle = function () {
// Store sidebar minimize state in cookie
toggleObj.on("kt.toggle.changed", function() {
// In server side check sidebar_minimize_state cookie
// value and add data-kt-app-sidebar-minimize="on"
// attribute to Body tag and "active" class to the toggle button
var date = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000); // 30 days from now
var state = toggleObj.isEnabled() ? "on" : "off";
KTCookie.set("sidebar_minimize_state", toggleObj.isEnabled() ? "on" : "off", {expires: date});
});
}