I put a form inside a bootstrap dropdown, but when I click any of the fields in the form, the dropdown goes away. I have this piece of code but I don\'t know where to put it
If you look to the bottom of sources of dropdown widget, you will see this:
$(document)
.on('click.bs.dropdown.data-api', '.dropdown form', function(e) {
e.stopPropagation()
})
So you have the following choices:
- Simply wrap yor dropdown with form
- Or you can add event listener for click event of .dropdown YOUR_SELECTOR
$(document)
.on('click.my', '.dropdown some_selector', function(e) {
e.stopPropagation()
})