Javascript 在Firefox的引导模式下,Sweet Alert中的文本框无法聚焦

Javascript 在Firefox的引导模式下,Sweet Alert中的文本框无法聚焦,javascript,firefox,bootstrap-modal,sweetalert,sweetalert2,Javascript,Firefox,Bootstrap Modal,Sweetalert,Sweetalert2,我有一个包含文本框的sweetalert框。sweetalert在引导模式框中打开。在Firefox中,我试图点击文本框,但它没有获得焦点 这是我的甜蜜警报代码: swal( { title: "Create New Design", input: "text", showCancelButton: true, inputPlac

我有一个包含文本框的sweetalert框。sweetalert在引导模式框中打开。在Firefox中,我试图点击文本框,但它没有获得焦点

这是我的甜蜜警报代码:

swal(
        {
            title:              "Create New Design",
            input:              "text",
            showCancelButton:   true,
            inputPlaceholder:   "Title",
            preConfirm: function(input)
            {
                // code to validate the input
            }
        });
这是截图:


根据@limonte在评论中给出的已知问题,Boostrap模态框有一个名为enforceFocus的函数,当我们试图聚焦到未包装在BS模态框中的元素时,该函数会立即将焦点放在模态本身上

现在,我所做的是从文档中取消绑定focusin.bs.modal事件,如下所示。它很好用

jQuery('#myModal').on('shown.bs.modal', function() {
    jQuery(document).off('focusin.modal');
});
除了彼此之间,我们没有其他解决方案

我们可以使用以下行覆盖该特定方法:

jQuery.fn.modal.Constructor.prototype.enforceFocus = function () { };

根据@limonte在评论中给出的已知问题,Boostrap模态框有一个名为enforceFocus的函数,当我们试图聚焦到一个未包装在BS模态框中的元素时,它会立即将焦点放在模态本身上

现在,我所做的是从文档中取消绑定focusin.bs.modal事件,如下所示。它很好用

jQuery('#myModal').on('shown.bs.modal', function() {
    jQuery(document).off('focusin.modal');
});
除了彼此之间,我们没有其他解决方案

我们可以使用以下行覆盖该特定方法:

jQuery.fn.modal.Constructor.prototype.enforceFocus = function () { };

首先,你使用的是,不是SweetAlert。这两个项目是不同的。这个问题可能会有所帮助:非常感谢。它帮助了很多首先,你正在使用,而不是SweetAlert。这两个项目是不同的。这个问题可能会有所帮助:非常感谢。它帮助了很多
jQuery.fn.modal.Constructor.prototype.enforceFocus=function(){}工作,JSFIDLE:
jQuery.fn.modal.Constructor.prototype.enforceFocus=function(){}工作,JSFIDLE: