Bootstrap dropdown closing when clicked

后端 未结 9 2447
南旧
南旧 2020-11-29 02:00

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

9条回答
  •  孤街浪徒
    2020-11-29 02:23

    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:

    1. Simply wrap yor dropdown with form
    2. Or you can add event listener for click event of .dropdown YOUR_SELECTOR
    $(document)
      .on('click.my', '.dropdown some_selector', function(e) {
        e.stopPropagation()
      })
    

提交回复
热议问题