Bootstrap level 3 menu style, support master page retention open state implementation method _javascript tips

Source: Internet
Author: User

Razor View, master page

Still not much to say, directly on the code

<ul class= "Sidebar-menu" > @for (int i = 0; i < Mlist.count; i++) {if (mlist[i). Fatherid = = 0) {mclist = Getchild (mlist[i). ModuleID, mlist);<!--A collection of level two menus--> <li class= "treeview" ><a href= "#" ><i class= "FA Fa-folder-o "></i><span> @mList [i]. Modulename</span><i class= "fa fa-angle-left pull-right" ></i></a><!--level menu--> &L
                  T;ul class= "Treeview-menu" > @for (int j = 0; J < Mclist.count; J +)//two-level loop { if (mclist[j). Fatherid = = 41//If CRM then enter this loop {mslist = Getchild (mclist[j).  ModuleID, mlist); <!--level Three menu collection--> <li><a href= "javascript:void (0);" Data-id= "@mCList [j]. ModuleID "><i class=" fa fa-share "></i> @mCList [j]. Modulename<i class= "fa fa-angle-left pull-right" ></i></a><!--level two dishesSingle--> <ul class= "Treeview-menu" > @for (int k = 0; k < Mslist.count; k + +)//Level three menu Loop {if (! String.IsNullOrEmpty (Mslist[k]. Roteurl)) {<li><a href= "@Url. Content (mslist[k). Roteurl)? cid= @mSList [K]. ModuleID "Data-id=" @mSList [K]. ModuleID "><i class=" fa fa-circle-o "></i> @mSList [K].
                        Modulename</a></li> <!--level three menu--> i++; else {<li><a href= "javascript: void (0) "data-id=" @mSList [K]. ModuleID "><i class=" fa fa-circle-o "></i> @mSList [K].
                        Modulename</a></li> <!--level three menu--> i++;
}} </ul> </li>                      i++; else//Not CRM enters this {if (!) String.IsNullOrEmpty (Mclist[j]. Roteurl)) {<li><a href= "@Url. Content (MCLIST[J). Roteurl)? cid= @mCList [j]. ModuleID "Data-id=" @mCList [j]. ModuleID "><i class=" fa fa-circle-o "></i> @mCList [j].
                    Modulename</a></li> <!--level two menu--> i++; else {<li><a href= "javascript:void (0);" data-id= "@mC LIST[J]. ModuleID "><i class=" fa fa-circle-o "></i> @mCList [j].
                    Modulename</a></li> <!--level two menu--> i++;
        }} </ul> </li>}} </ul>

Here's the point.

$.widget.bridge (' UIButton ', $.ui.button);
      var _url = $.geturlparam ("cid");
      $ (". Sidebar-menu li a"). each (function () {//Reserved menu open Status
        var _id = $ (this). Data ("id");
        if (_id = = _url) {
          $ (this). Parent (). Parent (): Show ();
        }
      });

      $ (". Sidebar-menu li a"). Click (function () {
        $ (this). AddClass ("");
      })

    };

Ways to get Menu parameters

(function ($) {
  $.geturlparam = function (name) {
    var reg = new RegExp (^|&) + name + = ([^&]*) (&| $)"); Constructs an object with a regular expression with a target parameter
    var r = window.location.search.substr (1). Match (reg);//Match target parameter
    if (r!= null) {
      Return unescape (r[2]); Returns the parameter value
    } else {return
      null;}}}
) (JQuery);

Effect chart

The above is a small series for everyone to bring the bootstrap Level 3 menu style, support master page retention open State implementation of the whole content, I hope that we support cloud-Habitat Community ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.