BootStrap3在点击项目后,保持下拉菜单打开 [英] BootStrap3 keep the dropdown menu open after click on the item

查看:133
本文介绍了BootStrap3在点击项目后,保持下拉菜单打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用bootstrap3.0,它具有优秀的下拉菜单。



如果我点击下拉菜单的一侧,菜单将消失,这是对的。



但是当我点击下拉菜单中的项目时,它也会消失。这不是我认为的,没有选择可以控制它的切换行为。 (我需要菜单保持打开,当我点击项目,像Facebook通知菜单)



所以我想我必须修改引导源,我去真的很想。所以在我触摸源之前,我想知道有没有什么好的工作?如果没有,如何更改源的最小影响的引导?



感谢任何想法。

解决方案

点击后保持下拉菜单打开...

  $('#myDropdown')。on('hide.bs.dropdown' ,function(){
return false;
});

演示: http ://www.bootply.com/116350



另一个选项是处理像这样的点击事件..


$ ({
click:function(e){
e.stopPropagation($ {
pre $ ();
}
});

演示: http ://www.bootply.com/116581


I'm using bootstrap3.0, with it excellent drop-down menu.

If I click out side of the drop-down menu the menu will disappear, and this is quite right.

but when I click on the item of the drop-down menu, it will disappear as well. this is not that right I think, and there is no options can control it's toggle behavior. (I need the menu keep open when I click on the items, like the facebook notification menu)

so I think I have to modify the source of bootstrap, which I don't really want to. so before I touch the source, I want to know is there any good work-around? if not, How to change the source for minimum impact of bootstrap?

thanks for any idea.

解决方案

Here is one way to keep the dropdown open after click...

$('#myDropdown').on('hide.bs.dropdown', function () {
    return false;
});

Demo: http://www.bootply.com/116350

Another option is to handle the click event like this..

$('#myDropdown .dropdown-menu').on({
    "click":function(e){
      e.stopPropagation();
    }
});

Demo: http://www.bootply.com/116581

这篇关于BootStrap3在点击项目后,保持下拉菜单打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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