Bootstrap模态恢复按钮焦点关闭

sta*_*low 13 css twitter-bootstrap

我很难与一种效果斗争,我相信在Bootstrap中需要它,但我想逃避.我有按钮:

<a data-toggle="modal" data-target="#video" class="btn btn-primary btn-lg" href="#">Video<i class="pe-7s-angle-right pe-2x pe-va" style="line-height: 0.3;"></i></a>
Run Code Online (Sandbox Code Playgroud)

其中包含一些视频打开模态窗口:

<div class="modal fade video-lightbox in" id="video" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: block;"><div class="modal-backdrop fade in" style="height: 442px;"></div>
Run Code Online (Sandbox Code Playgroud)

所以当我关闭模态时,我的按钮会自动聚焦.这个效果是否需要在Bootstrap中,我该如何逃避呢?关闭模态后,我不希望我的按钮处于焦点.

spi*_*itz 8

模态关闭时模糊按钮。

$('body').on('hidden.bs.modal', '.modal', function() {
    $('.btn').blur();
}); 
Run Code Online (Sandbox Code Playgroud)


sta*_*low 0

通过删除解决了这个问题

d.trigger("focus")    
Run Code Online (Sandbox Code Playgroud)

在 bootstrap.min.js 中:

a.fn.modal = b, a.fn.modal.Constructor = c, a.fn.modal.noConflict = function() {
    return a.fn.modal = d, this
}, a(document).on("click.bs.modal.data-api", '[data-toggle="modal"]', function(c) {
    var d = a(this),
        e = d.attr("href"),
        f = a(d.attr("data-target") || e && e.replace(/.*(?=#[^\s]+$)/, "")),
        g = f.data("bs.modal") ? "toggle" : a.extend({
            remote: !/#/.test(e) && e
        }, f.data(), d.data());
    d.is("a") && c.preventDefault(), f.one("show.bs.modal", function(a) {
        a.isDefaultPrevented() || f.one("hidden.bs.modal", function() {
            d.is(":visible") && d.trigger("focus")
        })
    }), b.call(f, g, this)
})
Run Code Online (Sandbox Code Playgroud)