Adminlte: Open Sidebar Menu Treeview Link based on Current Link

Created on 29 Nov 2016  路  2Comments  路  Source: ColorlibHQ/AdminLTE

Thanks for the awesome theme. I am trying to open treeview menu link using jquery where the page height is not setting properly.

var url = location.pathname;
$('a[href*="'+url+'"]').parents('.treeview').addClass('active');

Most helpful comment

Here are my two solutions for this, it's similar to your's:

var url = location.pathname;
if($('a[href*="'+url+'"]').length > 0) {
    $('a[href*="'+url+'"]').parents('li').addClass('active').parents('.treeview').addClass('active');
}

var lastSegment = url.split('/').pop();
if($('a[href*="'+lastSegment+'"]').length > 0) {
    $('a[href*="'+lastSegment+'"]').parents('li').addClass('active').parents('.treeview').addClass('active');
}

All 2 comments

Here are my two solutions for this, it's similar to your's:

var url = location.pathname;
if($('a[href*="'+url+'"]').length > 0) {
    $('a[href*="'+url+'"]').parents('li').addClass('active').parents('.treeview').addClass('active');
}

var lastSegment = url.split('/').pop();
if($('a[href*="'+lastSegment+'"]').length > 0) {
    $('a[href*="'+lastSegment+'"]').parents('li').addClass('active').parents('.treeview').addClass('active');
}

Still the issue persists, if the sidebar height has scroll, it doesn't adjusts after it opens.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fromberg100 picture fromberg100  路  4Comments

vbetancourt picture vbetancourt  路  3Comments

jrlooney picture jrlooney  路  3Comments

acacha picture acacha  路  4Comments

frlinw picture frlinw  路  3Comments