Reputation: 29444
This has been asked for an older version, but no satisfying answer.
When viewed on small screen, the jQuery Mobile doc uses a multi-level menu panel that slides in when tapped.
I tried copying the code but this is all I got:
Apparently you also need to specify data-role="collapsible"
on li
s with sub-menu, and some other attributes, which is not really ideal.
Surely there are people who use jQuery Mobile who also need the menu on their mobile website. But it is nowhere in the documentation.
Has anyone figured out how to do it without reinventing the wheel?
Or does jQuery Mobile simply not support this kind of menu without manually coding everything?
Upvotes: 2
Views: 1645
Reputation: 31732
If you check page source, you will notice that ul
s' within the panel have no data-role="listview"
and li
s' that contains sub-elements are given data-role="collapsible"
.
That's not all, on mobileinit
event, the aforementioned ul
s' are converted into listview using the below code.
$(".jqm-navmenu-panel ul").listview();
Moreover, padding
and margin
are removed/modified on all panel's elements to get them stick to each others.
.jqm-navmenu-panel .ui-listview > li .ui-collapsible-heading {
margin: 0;
}
.jqm-navmenu-panel .ui-collapsible.ui-li-static {
padding: 0;
border: none !important;
}
.jqm-navmenu-panel .ui-collapsible + li > .ui-btn,
.jqm-navmenu-panel .ui-collapsible + .ui-collapsible > .ui-collapsible-heading > .ui-btn,
.jqm-navmenu-panel .ui-panel-inner > .ui-listview > li.ui-first-child .ui-btn {
border-top: none !important;
}
.jqm-navmenu-panel .ui-listview .ui-listview .ui-btn {
padding-left: 1.5em;
color: #999;
}
.jqm-navmenu-panel .ui-listview .ui-listview .ui-btn.ui-btn-active {
color: #fff;
}
.jqm-navmenu-panel .ui-btn:after {
opacity: .4;
filter: Alpha(Opacity=40);
}
.jqm-navmenu-panel ul li:first-child a{
border-top: none;
}
Upvotes: 3