question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sidebar menu with sub menus - cannot expand to access sub-menus

See original GitHub issue

Issue type:

  • Feature request
  • Bug report
  • Documentation

Environment:

  • AdminLTE Version: 2.4.10 with Angular 7
  • Operating System: Windows 10
  • Browser (Version): Recent Chrome (Electron)

Description:

The same issue was reported many times with the sidebar menu not expanding when clicked to access the sub-menus => can not access the sub-menus. I tried without success all things suggested here - https://github.com/ColorlibHQ/AdminLTE/issues/1666 and here https://github.com/ColorlibHQ/AdminLTE/issues/1570

What was tried

  1. Loading Admin LTE globally in the angular.json under the scripts section like this
"scripts": [
              "./node_modules/jquery/dist/jquery.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.min.js",
              "./node_modules/admin-lte/dist/js/adminlte.min.js"
]

In the html I have <ul class="sidebar-menu" data-widget="tree">

When I try to execute

 $(document).ready(() => {
      const trees: any = $('[data-widget="tree"]');
      if (trees) {
        trees.tree();
      }
    });

I get the error .tree() function was not found. The user @thiagoreis got the same error here https://github.com/ColorlibHQ/AdminLTE/issues/1570. Later @thiagoreis suggested a solution which without success (I tried but I get the same error).

  1. I removed adminlte.min.js from angular.json scripts and tried to load using import 'admin-lte' (did not work) and then I tried also require ('admin-lte') - did not work either I always get the same error .tree() function was not found

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
gongAllcommented, Sep 12, 2019

In case anyone is struggling with this, this thread was really helpful: (https://stackoverflow.com/questions/45512475/angular4-cant-find-jquery-ui-functions) – look for the answer of Chris and after applying it, follow the code:

$(document).ready(() => {
      const trees: any = $('[data-widget="tree"]');
      if (trees) {
        trees.tree();
      }
    });

on the ngOnInit of your component

0reactions
magicdictcommented, Sep 25, 2019

In case anyone is struggling with this, this thread was really helpful: (https://stackoverflow.com/questions/45512475/angular4-cant-find-jquery-ui-functions) – look for the answer of Chris and after applying it, follow the code:

$(document).ready(() => {
      const trees: any = $('[data-widget="tree"]');
      if (trees) {
        trees.tree();
      }
    });

on the ngOnInit of your component

Great!!! It really works!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a menu with sub-options (collapsible sub-menus) in ...
Your browser can't play this video. Learn more.
Read more >
issues collapsing nested javascript menus - Stack Overflow
I have a sidebar navigation menu (HTML5/CSS/Vanilla JavaScript) that acts like an accordion with multiple levels of nested menus.
Read more >
Targeting Menu Elements with Submenus in a Navigation Bar
The common way to address this issue, is to simply add a class to the <li> s that contain <ul> s (sub menus)...
Read more >
Internet Explorer: Not expanding the sub-menus
On the left side, there is a menu 'Contributions Caps". Using a click on its + sign I can expand it. However when...
Read more >
Fix to the SUB-MENU problem on MOBILE DEVICES: Revisted
This problem was resolved on the forum. This write up is just to clarify the steps required to get the Menu to display...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found