0
問題在於,單擊邊欄後,子菜單會短暫出現並再次隱藏。(Angularjs Metronic)邊欄子菜單隱藏後點擊並不保持打開
Layout.js(效果基本show FUNC。)被觸發兩次廢話
我檢查了app.js和設置菜單的ID。我確信我存儲在數據庫中的id和sub id正常工作。我檢查了網頁上的課程正常工作並正確放置。
但是,「open」類及其關聯的「顯示塊」樣式存在問題。如果我去修復它並保持在metronic layout.css中,重要的輸入仍然可見。但在它再次打開和關閉之前。
謝謝你的幫助。
-Metronic.factory在app.js
var settings = {
layout: {
pageSidebarClosed: false, // sidebar menu state
pageBodySolid: false, // solid body color state
pageAutoScrollOnLoad: 1000 // auto scroll to top on page load
},
...
};
-MetronicApp.controller在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(); // init sidebar
},
function (error) {
alert("Error");
});
};
}]);
邊欄視圖(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主題全局腳本)
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流量日誌(工作和不工作的版本)
順便說一句,側欄懸停菜單工作p roperly。但我需要默認側邊欄 – OkurYazar
LoadMenus在app.js中觸發兩次... – OkurYazar