单击列表时使用 bootstrapDropdown 防止下拉菜单消失 [英] Prevent the disappear of Dropdown menu using bootstrapDropdown when clicking on the list

查看:23
本文介绍了单击列表时使用 bootstrapDropdown 防止下拉菜单消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 bootstrap-dropdown 生成下拉菜单.我想防止菜单在点击时消失.

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?

<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);
},

推荐答案

您是否尝试过 event.stopPropagation?

onClickNotification: function (e) {
    e.stopPropagation();
    console.log(e)
},

这篇关于单击列表时使用 bootstrapDropdown 防止下拉菜单消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆