0

Django Web サイトの AdminLTE サイドバーの作業をいくつか継承しました。問題のページは、「extends」ブロックを使用して、すぐに AdminLTE の index.html ページをロードします。ツリービュー サイドバーにリンクがあると、サイドバーを含むページ全体がリロードされるため、誰かがリンクをクリックすると、展開されたツリービュー メニューの状態が失われます。

サイドバーにツリービュー メニューを開いたままにするよく知られた方法があると思いますが、まだ見つけていません。AdminLTE サイトにいくつかの実用的な例がありますが、それらがどのように機能するかわかりません。

ページが読み込まれてもサイドバーが持続するようにするための適切なドキュメントを教えてもらえますか?

4

4 に答える 4

1

Treeview css クラスは順序付けされていないリストで機能するため、親リストがクリックされた場合にのみ子リンクが表示されます。この例は、「ホーム」の次に「About」「About-Locations」がある場合です。[About] をクリックすると、ツリー ビュー クラスになり、サイドバーにその下の場所が表示されます。ホームをクリックすると、場所のサイドバー リンクは表示されません。これは、リストの CSS がこのように記述されているためです。

コードは「AdminLTE.css」ファイルにあります。

于 2016-06-27T19:34:05.523 に答える
0

参考までにコードはこちら。

/* 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;
    $(menu).on('click', '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();
      }
    });
  };
于 2016-08-11T15:46:22.157 に答える