我有一个 mmenu 实例。默认行为是当我在菜单外单击时它会关闭。我怎样才能防止这种行为?要强制关闭菜单,我只想使用一个预先设置的按钮(已经工作)
------------------ 添加一些细节 --------
我的 mmenu 实例如下
<nav id="listPanel">
<ul>
<li id="closeButtonLi"><span id="panelButtonClose" class="glyphicon glyphicon-chevron-right"> Chiudi</span></li>
<!--<li style="padding:10px"><input type="text" class="form-control" placeholder="Aggiungi atleta"></li>-->
<li id="athSelectorLi" style="padding:10px">
<input id="athSelector" style="width:70%;"/>
<img id="plusButton" style="width:35px;height:auto;cursor:pointer;margin-left:12px;" src="../../../docsUI/images/common/add.png"/>
<img id="removeButton" style="width:35px;height:auto;cursor:pointer;margin-left:7px;" src="../../../docsUI/images/common/remove.png"/>
</li>
<li >
<table id="athTable" class="hover compact" width="95%" cellspacing="0">
<thead>
<tr>
<th>markerColor</th>
<th>bib</th>
<th>name</th>
<th>avgSpeed</th>
<th>locate</th>
<th>remove</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</li>
</ul>
</nav>
$(document).ready(function() {
$("#listPanel").mmenu({
"classes": "mm-light",
"offCanvas": {
"zposition": "front",
"position": "right"
}
}
});
$("#panelButton").click(function() {
$("#listPanel").trigger("open.mm");
});
$("#panelButtonClose").click(function() {
$("#listPanel").trigger("close.mm");
});
});
我需要的是仅使用关闭按钮关闭#listPanel 菜单
<li id="closeButtonLi"><span id="panelButtonClose" class="glyphicon glyphicon-chevron-right"> Chiudi</span></li>
在当前实现中,按钮按预期工作,但是当我在页面其余部分的菜单外部单击时,菜单也会关闭。我想完全避免它(关闭菜单单击页面,这是http://mmenu.frebsite.nl/tutorial/open-and-close-the-menu.html中描述的默认行为)
我在 Stack Overflow 当前答案和网站文档上都进行了搜索,但没有找到任何解决方案。唯一存在的 API 是 onClick,但它与我的需求无关。