在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ AdminLTE.tree 導(dǎo)航點(diǎn)擊如何全部展開

AdminLTE.tree 導(dǎo)航點(diǎn)擊如何全部展開

使用AdminLTE.tree 導(dǎo)航點(diǎn)擊如何全部展開?

目前AdminLTE.tree側(cè)邊欄導(dǎo)航,點(diǎn)擊一個(gè)菜單另外一個(gè)active菜單就自動(dòng)折疊。能否不自動(dòng)折疊?請(qǐng)大神指點(diǎn)。

code如下:

/* Tree()

  • ======
  • Converts the sidebar into a multilevel
  • tree view menu.

*

  • @type Function
  • @Usage: $.AdminLTE.tree('.sidebar')

*/
$.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();
    }
  });

};

回答
編輯回答
只愛你

自己解決了其實(shí)就是

//注釋
var ul = parent.find('ul:visible').slideUp(animationSpeed);
ul.removeClass('menu-open');

//注釋 removeClass("avtive")
parent.find('li.active').removeClass('');

代碼如下:
$.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('');
        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();          
    }
  });

};

2018年9月14日 12:44