单击该项目后,BootStrap3 保持下拉菜单打开 [英] BootStrap3 keep the dropdown menu open after click on the item
问题描述
我正在使用 bootstrap3.0,它具有出色的下拉菜单.
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.
但是当我点击下拉菜单的项目时,它也会消失.我认为这不是正确的,并且没有选项可以控制它的切换行为.(当我点击项目时,我需要菜单保持打开状态,比如 Facebook 通知菜单)
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?
感谢您的任何想法.
推荐答案
这是一种在点击后保持下拉菜单打开的方法...
Here is one way to keep the dropdown open after click...
$('#myDropdown').on('hide.bs.dropdown', function () {
return false;
});
演示:http://www.bootply.com/116350
另一种选择是像这样处理点击事件..
Another option is to handle the click event like this..
$('#myDropdown .dropdown-menu').on({
"click":function(e){
e.stopPropagation();
}
});
演示:http://www.bootply.com/116581
这篇关于单击该项目后,BootStrap3 保持下拉菜单打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!