Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

twitter bootstrap - BootStrap3 keep the dropdown menu open after click on the item

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...