i am using twitter bootstrap for my project.
I want to add checkboxes in dropdown, something similar to http://jsfiddle.net/qG7c4/
File: bootstrap-dropdown.js
Example: http://twitter.github.com/bootstrap/javascript.html#dropdowns
problem is, that dropdown get closed on click of every checkbox, i don't want this to be closed on click of checkbox, so that user can select multiple checkboxes easily.
What changes i need to do in javascript for this?
Add the checked attribute to the <input> element in order to pre-select the checkbox when the page loads. The checked attribute is a boolean attribute. The checked attribute can be used with <input type="checkbox"> and <input type="radio"> .
Basic Dropdown To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. Add the . dropdown-menu class to a <div> element to actually build the dropdown menu.
Answer: Use the jQuery hover() method By default, to open or display the dropdown menu in Bootstrap you have to click on the trigger element. However, if you want to show the dropdown on mouseover instead of click you can do it with little customization using the CSS and jQuery.
Try stopping the propagation of the click event on your input elements like so:
$('.dropdown-menu input, .dropdown-menu label').click(function(e) {
e.stopPropagation();
});
Demo
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