I have a Bootstrap dropdown menu I plan to use to login. It appears fine but when I select the username nput it vanishes since the focus has gone to the input. How would I go about adding in support for the inputs or is there a working method for this?
My current code is:
<li id="fat-menu" class="dropdown">
<a href="#" id="drop3" role="button" class="dropdown-toggle" data-toggle="dropdown" data-target="#">Login <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
<li role="presentation"><input name="username" type="text" placeholder="Username" /></li>
<li role="presentation"><input name="password" type="password" placeholder="Password" /></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Login</a></li>
</ul>
</li>
My attempt at jsfiddle. I couldnt get the dropdown to work at all: http://jsfiddle.net/KF8dv/
Please see this :- http://jsfiddle.net/b8769/
You need to prevent dropdown event when clicked on input text boxes. You can achhive this by using javascript. stopPropagation
$('.dropdown-menu input').click(function(e) {
e.stopPropagation(); //This will prevent the event from bubbling up and close the dropdown when you type/click on text boxes.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With