Updated script
You only need to make one change:
Instead of listening for the .dropdown.active event for hide.bs.dropdown only, apply the event handler to .dropdown .
Basically, change:
$(".dropdown.active").on("hide.bs.dropdown",function(e) {
at
$(".dropdown").on("hide.bs.dropdown",function(e) {
EDIT: To override the default behavior of the drop-down list, you will need to ignore the active state, since more than one li element can remain extended, and you will need to switch the visibility yourself.
Here's an updated demo
The code:
$(function(){ // Handle show/hide toggle yourself $(".dropdown").on("click",function(e) { if($(e.currentTarget).hasClass("open")) $(e.currentTarget).toggleClass("open",false); else $(e.currentTarget).toggleClass("open",true); e.preventDefault(); return false; }); // suppressing default bahavior $(".dropdown").on("hide.bs.dropdown", doNothing); $(".dropdown").on("show.bs.dropdown", doNothing); function doNothing(e) { e.preventDefault(); return false; } });
Vikram Deshmukh Feb 11 '14 at 5:47 a.m. 2014-02-11 05:47
source share