Twitter Bootstrap modal blocks text input field

前端 未结 11 1174
野趣味
野趣味 2020-12-02 18:42

I am trying to use a modal as a popup help window. I set backdrop to \'nothing\'. When the modal is opened (without backdrop) input fields in \'original\' page cannot be foc

11条回答
  •  醉酒成梦
    2020-12-02 18:52

    Following worked for me:

    $('#myModal').on("show.bs.modal", (ev) => {
        $('#myModal').find(".modal-content").on("mousedown", (e) => {
    
                    if ($(e.target).is("input")) {
                        //Fix for bootstrap modal being stealing focus from inputs like textbox
                        e.stopImmediatePropagation();
                    }
                });
    });
    

提交回复
热议问题