AdminLTE 子菜单展开然后折叠
AdminLTE submenu expands then collapses
我在其他人启动的项目中使用 AdminLTE
添加子菜单时我看到的行为是它展开然后立即折叠
我尝试使用索引.html页面的完整<aside class="main-sidebar">...</aside>
,但仍然得到与此处相同的行为 - https://gyazo.com/e88b049ccd7b2d06d65ccc7986166cdf
如果我从本地模板打开索引.html它可以正常工作
我认为这个项目可能缺少一些东西,但无法弄清楚是什么......尝试加载所有js,我在控制台中没有看到任何错误
任何帮助将不胜感激
侧边栏行为不是由 index.html 文件控制,而是由位于 adminlte 的/dist/js 文件夹中的 app.js 文件控制。您的项目中必须有此文件(以及其他文件)。
我的建议是首先查看您的应用程序.js文件是否没有被以前从事该项目的人修改,或者您是否可以在其他地方使用一些覆盖默认侧边栏行为的脚本。
控制左侧边栏的原始代码从 app.js 文件 (adminlte v2.3.6) 的第 380 行开始,如下所示:
$.AdminLTE.tree = function(menu) {
var _this = this;
var animationSpeed = $.AdminLTE.options.animationSpeed;
$(document).off('click', menu + ' li a')
.on('click', menu + ' li a', function(e) {
//Get the clicked link and the next element
var $this = $(this);
var checkElement = $this.next();
//Check if the next element is a menu and is visible
if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
//Close the menu
checkElement.slideUp(animationSpeed, function() {
checkElement.removeClass('menu-open');
//Fix the layout in case the sidebar stretches over the height of the window
//_this.layout.fix();
});
checkElement.parent("li").removeClass("active");
}
//If the menu is not visible
else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
//Get the parent menu
var parent = $this.parents('ul').first();
//Close all open menus within the parent
var ul = parent.find('ul:visible').slideUp(animationSpeed);
//Remove the menu-open class from the parent
ul.removeClass('menu-open');
//Get the parent li
var parent_li = $this.parent("li");
//Open the target menu and add the menu-open class
checkElement.slideDown(animationSpeed, function() {
//Add the class active to the parent li
checkElement.addClass('menu-open');
parent.find('li.active').removeClass('active');
parent_li.addClass('active');
//Fix the layout in case the sidebar stretches over the height of the window
_this.layout.fix();
});
}
//if this isn't a link, prevent the page from being redirected
if (checkElement.is('.treeview-menu')) {
e.preventDefault();
}
});};
相关文章:
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- ExtJS——在展开/折叠时调整面板高度
- Javascript运行php文件,然后下载文件
- 如何将屏幕分辨率乘以 80%,然后在代码中使用
- 弹出窗口出现,然后退出
- 如何在JQuery函数中定义一个值,然后调用另一个函数并使用该值
- 将值输入到对象,然后该对象推送到数组
- 如何临时暂停浏览器渲染,然后恢复整个页面
- JS:检查URL中的参数,然后迭代一个参数为var的函数
- 展开和折叠文件夹
- 展开和折叠自举手风琴
- 滚动然后捕捉到顶部而不是取消捕捉
- AngularJS加载JSON数据,然后从中解析/加载HTML
- 默认情况下折叠和展开嵌套列表
- 有没有一个抽象层,这样我就可以集成一次,然后使用pusher、pubnub或faye
- Canvas+svg路径动画,在路径中的特定点暂停一段时间,然后继续
- 如果30秒未单击,请应用CSS一次,将其删除,然后重新迭代
- 把鼠标移过去,然后把鼠标移出去.悬停时折叠内容标头
- AdminLTE 子菜单展开然后折叠
- 首先需要折叠子菜单,然后使用jQuery折叠第一个菜单