Skip to content

Instantly share code, notes, and snippets.

@rwaddin
Last active May 4, 2021 15:30
Show Gist options
  • Save rwaddin/d5adff0129e8dc9239a5ed48915f1490 to your computer and use it in GitHub Desktop.
Save rwaddin/d5adff0129e8dc9239a5ed48915f1490 to your computer and use it in GitHub Desktop.
set active adminlte
$(document).ready(function(){
/** add active class and stay opened when selected */
let url = window.location;
// for sidebar menu entirely but not cover treeview
$('ul.sidebar-menu a').filter(function() {
return this.href === url.href;
}).parent().addClass('active');
// for treeview
$('ul.treeview-menu a').filter(function() {
return this.href === url;
}).parentsUntil(".sidebar-menu > .treeview-menu").addClass('active');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment