When using MVC Route on Sidebarmenu, current page is not activated on the menu. Could you please help?
Answered on previous post, this works for me :
<script>
KTUtil.onDOMContentLoaded(function() {
KTMenu.updateByLinkAttribute(window.location.pathname);
});
</script>
Hi ,
Glad to hear that If you need any further assistance please let us know.
Regards.
Hi,
I have the same problem: I am applying Metronic theme 8.1.5 to existing MVC 5 application. After clicking on sidebar menu, current page is not activated on menu. I checked ASP.NET Core sample Starterkit and there is the same problem.
How do I use code from the previous post?
Thanks for your answer,
Regards, Valentin
when using with htmx, I am getting "menu-item menu-accordion showing" even when i click on a menu outside the tree ( happens when I click on a nested item, and then click on an outside item ). tried both of these
KTUtil.onDOMContentLoaded(function() {
console.log("active link: " + window.location.pathname);
KTMenu.updateByLinkAttribute(window.location.pathname, "hx-get");
});
document.addEventListener("htmx:afterSwap", function(event) {
console.log("active link: " + window.location.pathname);
KTMenu.updateByLinkAttribute(window.location.pathname, "hx-get");
});
for menu links like this
<a
class="menu-link"
hx-get="/admin"
hx-target="#kt_app_content"
hx-swap="outerHTML"
hx-push-url="true">
when using with htmx, I am getting "menu-item menu-accordion showing" even when i click on a menu outside the tree ( happens when I click on a nested item, and then click on an outside item ). tried both of these
KTUtil.onDOMContentLoaded(function() {
console.log("active link: " + window.location.pathname);
KTMenu.updateByLinkAttribute(window.location.pathname, "hx-get");
});
document.addEventListener("htmx:afterSwap", function(event) {
console.log("active link: " + window.location.pathname);
KTMenu.updateByLinkAttribute(window.location.pathname, "hx-get");
});
for menu links like this
<a
class="menu-link"
hx-get="/admin"
hx-target="#kt_app_content"
hx-swap="outerHTML"
hx-push-url="true">