即使单击相同级别的“ li”项目,“下拉”子菜单仍保持打开状态。当我单击“查看草稿/过去的申请”和“注销”其他项目时,如何关闭下拉子菜单? 这是我的代码。
<div class="navbar-collapse collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right nav-item">
<li><a href="" ng-click="goHome()"><span class="glyphicon glyphicon-home"></span> <strong>Home</strong></a></li>
<li class="dropdown" data-ng-controller="rootController" uib-dropdown>
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" uib-dropdown-toggle>
<span class="glyphicon glyphicon-user"></span>
<strong>Welcome {{authentication.userName}}</strong>
</a>
<ul class="dropdown-menu" role="menu" uib-dropdown-menu >
<li class="dropdown-submenu" >
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-cog"></i> Manage Account</a>
<ul class="dropdown-menu" uib-dropdown-menu style="top:100%;right:100%">
<li role="menuitem" ><a data-ui-sref="ManageProfile" data-ng-click='go()'><i class="glyphicon glyphicon-pencil"></i> View/Edit Organisation Profile</a></li>
<li role="menuitem" ><a data-ui-sref="ManagePersonalProfile" data-ng-click='go()'><i class="glyphicon glyphicon-pencil"></i> View/Edit Personal Profile</a></li>
<li role="menuitem"><a data-ui-sref="AddBranch" data-ng-click='go()'><i class="glyphicon glyphicon-edit"></i> Add Branch</a></li>
</ul>
</li>
<li>
<a data-ui-sref="SavedDraft" data-ng-click='go()'><i class="glyphicon glyphicon-record"></i> View Draft/Past Application</a>
</li>
<li>
<a href="javascript:;" data-ng-click="logOut()"><i class="glyphicon glyphicon-log-out"></i> Log Out </a>
</li>
</ul>
</li>
</ul>
</div>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$('ul.dropdown-menu [data-toggle=dropdown]').on('click', function (event) {
event.preventDefault();
event.stopPropagation();
$(this).parent().siblings().removeClass('open');
$(this).parent().toggleClass('open');
});
});
})(jQuery);
单击下拉菜单时出现此错误。我认为是因为jquery冲突。如何解决呢? 未捕获的错误:语法错误,无法识别的表达式:# 在Function.u.error(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1)处 在u.tokenize(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在u.select上(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在Function.u [找到](jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在i.fn.init.find(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在新的i.fn.init(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在我(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1) 在u(bootstrap?v = a0JlrK3HWJYO4CANWtnjZQ6r-FHTgFewh3ItuNGmfr41:1) 在HTMLAnchorElement。 (bootstrap?v = a0JlrK3HWJYO4CANWtnjZQ6r-FHTgFewh3ItuNGmfr41:1) 在Function.each(jqueryTest?v = TAv6ydUG1iyOHUWGhs7LKsQ8xhfxrCjB3MDSXsgtZS41:1)处
答案 0 :(得分:0)
您需要在每个li项目上使用data-target =“#myNavbar”将其关闭。