stackUnderflow stackUnderflow - 1 year ago 110
CSS Question

Bootstrap modal restores button focus on close

I am in very difficult struggle with one effect, which I believe is wanted in Bootstrap, but I want to escape. I have button:

<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>

Which opens modal window with some video:

<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>

So when I close the modal, my button gets in focus automatically. Is this effect wanted in Bootstrap and how can I escape it ? I don`t want my button to be in focus after closing the modal.

Answer Source

Resolved this by removing


in 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("", '[data-toggle="modal"]', function(c) {
    var d = a(this),
        e = d.attr("href"),
        f = a(d.attr("data-target") || e && e.replace(/.*(?=#[^\s]+$)/, "")),
        g ="bs.modal") ? "toggle" : a.extend({
            remote: !/#/.test(e) && e
        },,;"a") && c.preventDefault(),"", function(a) {
        a.isDefaultPrevented() ||"", function() {
  ":visible") && d.trigger("focus")
    }),, g, this)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download