AngularJS Metronic sidebar sub menu collapses after clicking and does not stay open

Upon clicking the sidebar, a brief appearance of the submenu followed by its immediate disappearance seems to be the core issue at hand.

The fact that Layout.js (slideUp func.) is triggered twice feels nonsensical

I meticulously combed through the settings in app.js as well as double-checked the id of the menus. I can confidently say that the id and sub id stored in the database are functioning correctly. All classes on the page seem to be in order and properly positioned.

However, a snag arises with the "open" class along with its corresponding "display block" style. Any attempts to rectify this within the metronic layout.css result in the crucial typing remaining visible momentarily before swiftly closing once more.

Your assistance on this matter is greatly appreciated.

-Metronic.factory in app.js

var settings = {
            layout: {
                pageSidebarClosed: false, // state of sidebar menu
                pageBodySolid: false, // state of solid body color
                pageAutoScrollOnLoad: 1000 // auto scroll duration on page load
            },
            ...
        };

-MetronicApp.controller in app.js

    MetronicApp.controller('SidebarController', 
    ['$scope', 'authService', function ($scope, authService) {    

    $scope.SelectMenu = function (id) {
        $scope.selectedMenu = id;
    }

    $scope.SelectChildMenu = function (id) {
        $scope.selectedChildMenu = id;
    }

    $scope.LoadMenus = function () {
        authService.UserMenus().then(function (response) {
                $scope.menus = response;
                Layout.initSidebar(); // initialize sidebar
            },
            function (error) {
                alert("Error");
            });
    };
    }]);
  • Sidebar view (.html)

    <div class="page-sidebar navbar-collapse collapse">
        <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200" ng-class="{'page-sidebar-menu-closed': settings.layout.pageSidebarClosed}" ng-controller="SidebarController" ng-init="LoadMenus()">
            <li class="start" ng:repeat="m in menus" ng-class="{'active open': m.id==selectedMenu}">
                <a href={{m.menuAction}} ng-click="SelectMenu(m.id)" >
                    <i class="icon-home"></i>
                    <span class="title">{{m.menuText}}</span>
                </a>
                <ul class="sub-menu" style="display: none;">
                    <li ng:repeat="child in m.children" ng-class="{'active': child.id==selectedChildMenu}" >                        
                        <a  ui-sref="{{child.menuAction}}"    >
                            <i class="icon-home"></i>
                            <span class="title">{{child.menuText}}</span>
                        </a>    
                    </li>
                </ul>    
            </li>        
        </ul>
    </div>   
    
  • layout.js (Metronic theme global script)

    if (sub.is(":visible")) {
                jQuery('.arrow', the).removeClass("open");
                the.parent().removeClass("open");
                debugger;// **This is also triggered immediately after a single click**
                sub.slideUp(slideSpeed, function () {
                    if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) {
                        if ($('body').hasClass('page-sidebar-fixed')) {
                            menu.slimScroll({
                                'scrollTo': (the.position()).top
                            });
                        } else {
                            Metronic.scrollTo(the, slideOffeset);
                        }
                    }
                    handleSidebarAndContentHeight();
                });
            } else if (hasSubMenu) {
                debugger; //first visit here normally
                jQuery('.arrow', the).addClass('open');
                the.parent().addClass('open');
                sub.slideDown(slideSpeed, function () {
                    if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) {
                        if ($('body').hasClass('page-sidebar-fixed')) {
                            menu.slimScroll({
                                'scrollTo': (the.position()).top
                            });
                        } else {
                            Metronic.scrollTo(the, slideOffeset);
                        }
                    }
                    handleSidebarAndContentHeight();
                });
            }
            e.preventDefault();
        });
    

CSS Flow Logs (Operational vs Malfunctioning versions)

Operational version:

Faulty version

Answer №1

To remove the ng-controller="sidebarController" directive when main.html is used in other views.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigation Bar with Dropdown Feature not Functioning Properly in CSS and HTML

I recently developed a website using CSS, HTML, and PHP. The main focus of my work has been on improving the navigation bar in the header section. However, after several hours of tweaking, I finally achieved the desired look for the navigation bar. Unfortu ...

Display the current page as it appears in AngularJS

I attempted to utilize the ngPrint directive from https://github.com/gilf/ngPrint for printing purposes. However, when I print the page, the design collapses entirely. Is there a solution to maintain the page layout when printing? Please note that Angula ...

Using Node.js and JWT: A guide to securely storing and using access tokens in the Authorization header

Has anyone encountered this issue before? I've searched extensively online but haven't found much information on the topic. I'm relatively new to using node and JWTs, and my goal is to generate a JWT and store it in the Authorization header ...

The timeline aesthetic can be achieved solely through the use of HTML, CSS, and potentially some Bootstrap functionalities

https://i.sstatic.net/EsDAE.png Up to this point, I've only been able to make it this far. I'm using a sample code from w3school https://i.sstatic.net/G1FcQ.png I've been attempting to get the year in the same position as in the image, bu ...

Issues with the functionality of AngularJS in the Chrome application

I am currently working on a chrome application that incorporates AngularJS in some sections. While the script functions perfectly in a web browser, it fails to work within my application. Moreover, the controller function is not getting called at all. In m ...

Understanding @@iterator in JavaScript: An in-depth look

Can someone shed some light on the mysterious @@iterator? It keeps popping up in tutorials but no one seems to provide a clear explanation of what it actually is. Is it a symbol literal or something else entirely? ...

List of characteristics belonging to objects contained within an array

Consider the following array of objects: data = [{x: 1, y: 2, z: 3}, {x: 4, y: 5, z: 6}, {x: 7, y: 8, z: 9}] Is there a way to extract only the x elements from these objects and create an array out of them? For example: x = [1, 4, 7] Can this be achiev ...

Using CSS to create sleek all-black Flaticons

After trying various solutions, I am still unable to fix this issue. I downloaded some icons and in the demo, they all appear as they should, with a more colorful aesthetic. Here is what the icons should look like: However, this is how the icons actually ...

Techniques for Utilizing MongoDB Aggregation to Extract Specific Fields from Results

Welcome, everyone! I'm diving into the world of MongoDB aggregation, and after running some queries, I've finally obtained the following result: "result" : [ { "_id" : "531d84734031c76f06b853f0" }, { "_id" : "5316739 ...

Using a function to identify and check dynamically added checkboxes

I am using a PHP page that loads a group of categories from another PHP script as checkboxes. Here is the format for the checkboxes: <input type='checkbox' class='cat-selector' id='Business' data-toggle='checkbox&apo ...

Adjust the parent element's height based on the child element's height, taking into consideration their respective positions

Is there a way to adjust the height of the parent element that has a relative position based on the height of child elements with absolute position? In the example below, the height of the .parent element is displaying as 0px Note: I am looking for a so ...

When a list item is clicked, extract its innerHTML and pass it to a JavaScript

Hey there, I've created a basic HTML/JavaScript calculator. Each time I perform a calculation, it gets added to the list shown on the webpage. Here's what I'm looking for: When a user clicks on an item in the list, I want to retrieve the s ...

Node.js tutorial: Fetching all pages of playlists from Spotify API

Currently, I am attempting to retrieve all of a user's playlists from the spotify API and display them in a selection list. The challenge lies in only being able to access 20 playlists at a time, which prompted me to create a while loop utilizing the ...

Tips for retrieving a nested data value within an array

I am currently puzzled by the undefined error I encounter when attempting to access a value using dot notation. The following illustrates my point: My goal is to retrieve the value from within the nested object in the headline color array: ...

Exploring Image Quality in Headless Browsers - A Comparison of Headless Chrome, PhantomJS, and Slimmer

Exploring the inner workings of headless browsers has been a fascinating journey for me. I have experimented with various headless browsers in the past, including SlimerJS, Phantom.js, and Headless Chrome, primarily for capturing screenshots of different w ...

Creating a Hidden Button on Your PWA: A Step-by-Step Guide

After creating a React app with Create React App, I decided to use the default PWA configuration. However, I am facing some confusion regarding how to hide the "Add to Home Screen" button. Can anyone provide some guidance on this issue? Thank you. https: ...

How to avoid line breaking in Select component with icon and text using React Material-UI

I am working on a Select element that includes both ListItemIcon and ListItemText. Whenever the select option is chosen, there seems to be an unwanted line break appearing. Despite finding various workarounds for this issue, I am keen on discovering the ...

Error encountered with the OpenAI Chat Completions API: "The request could not be completed, status code 404"

Currently, I am in the process of developing an application similar to ChatGPT using React and Axios for API requests to OpenAI's Chat Completions API. However, I have hit a roadblock as I keep encountering a 404 error when attempting to make a reques ...

Having issues with the functionality of the jQuery HTML function

I'm working on this jQuery code snippet: $('#wrapper').html('<img src="/loading.gif">'); var formdata = $("#validateuserform").serialize(); $.post("/userformdata.php",formdata,function(html){ if(html) ...

SliderToggle and Div implementation in Internet Explorer (IE) using jQuery

I'm encountering an issue with jQuery's slideToggle function and a div specifically in IE. Here is the code snippet causing the problem: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.d ...