admin管理员组文章数量:1292360
I am using using bootstrap-dropdown to generate a Dropdown menu. I would like to prevent the disappearing of the menu when click on it.
I have implemented the following code, but it does not work. Any idea how to fix it?
HTML
<li class="dropdown notification">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="notification-label label label-info">
<i class="icon-inbox icon-white"></i>
<span class="notification-number">{{ unread_notifications }}</span>
</span>
</a>
<ul class="dropdown-menu notification-list"></ul>
</li>
JS
events: {
'click ul.notification-list': 'onClickNotification'
},
onClickNotification: function (e) {
e.preventDefault();
console.log(e);
},
I am using using bootstrap-dropdown to generate a Dropdown menu. I would like to prevent the disappearing of the menu when click on it.
I have implemented the following code, but it does not work. Any idea how to fix it?
HTML
<li class="dropdown notification">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="notification-label label label-info">
<i class="icon-inbox icon-white"></i>
<span class="notification-number">{{ unread_notifications }}</span>
</span>
</a>
<ul class="dropdown-menu notification-list"></ul>
</li>
JS
events: {
'click ul.notification-list': 'onClickNotification'
},
onClickNotification: function (e) {
e.preventDefault();
console.log(e);
},
Share
edited Jul 31, 2012 at 15:10
merv
77.1k17 gold badges214 silver badges277 bronze badges
asked Jul 31, 2012 at 15:03
Lorraine BernardLorraine Bernard
13.4k23 gold badges85 silver badges138 bronze badges
2 Answers
Reset to default 8Did you try with event.stopPropagation
?
onClickNotification: function (e) {
e.stopPropagation();
console.log(e)
},
If you want to disable all auto closing of the dropdown you can just disable the listener
$('html').off('click.dropdown')
JSFiddle
本文标签:
版权声明:本文标题:javascript - Prevent the disappear of Dropdown menu using bootstrapDropdown when clicking on the list - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741553434a2385012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论