简体   繁体   English

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

[英]Textbox in Sweet Alert not focus-able while on bootstrap modal in Firefox

I've a sweetalert box that's containing a text box. 我有一个Sweetalert框,其中包含一个文本框。 The sweetalert is opened on a bootstrap modal box. 在引导模态框上打开sweetalert。 in Firefox, I'm trying to click in the text box but it is not getting the focus. 在Firefox中,我尝试单击文本框,但没有获得焦点。

Here is my Sweet Alert code: 这是我的Sweet Alert代码:

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

And this is the screenshot: 这是屏幕截图:

在此处输入图片说明

As per the known issue given by @limonte in the comment, the Boostrap modal box has a function called enforceFocus that immediately puts focus on the modal itself as soon as we try to focus into an element that is not wrapped in the BS modal box. 根据@limonte在评论中给出的已知问题,Boostrap模态框具有一个称为forceFenceFocus的函数,一旦我们尝试将焦点放在未包装在BS模态框中的元素,该函数立即将焦点放在模态本身上。

So for now what I've done is unbind that focusin.bs.modal event from the document like below. 因此,到目前为止,我要做的是从以下文档中取消绑定focusin.bs.modal事件。 It works fine. 工作正常。

jQuery('#myModal').on('shown.bs.modal', function() {
    jQuery(document).off('focusin.modal');
});

We don't have any other solutions to do that except one another. 除了彼此之外,我们没有其他解决方案。

We can possible override that particular method using below line: 我们可以使用下面的行覆盖该特定方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM