Bootstrap dropdown closing when clicked

后端 未结 9 2432
南旧
南旧 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:17

    Time passed since answer had been accepted, but if you want to keep the dropdown opened, if it acts like a kind of dialog, the best way i think is:

    $('.dropdown').dropdown().on("hide.bs.dropdown", function(e) {
                if ($.contains(dropdown, e.target)) {
                    e.preventDefault();
                //or return false;
                }
            });
    

提交回复
热议问题